我想使用Cypress中的MSW工作人员来灵活地模拟我的api请求的响应,以便为所有类型的测试提供一个通用的模拟工具。工作者设置中的MSW处理程序(在NextJs中)正在拦截来自Cypress测试运行的请求,没有任何问题。/test/server/testWorker.tsimport { handlers } from ".export * from "msw&q
我尝试过使用msw进行本地开发,并使用进行测试。但面临以下问题:
[MSW] Failed to register a Service Worker for scope ('http://localhost:8080/') with script (Did you forget to run "npx msw init <PUBLIC_DIR>"?
但是,问题是,当对运行MSW的本地版本运行testcafe测试时,我会收到以下消息。MSW Cannot intercept requests on this page because it's outside of the worker's scope ("http://localhost据我所知,MSW默认使用范围"/“,如果您不设置范围,而且我已经尝试显式设置它,并且似乎没有什么区别。我也尝试过设置标题,但我真的不知道我的意思是什么。我试过"/“