Closed efeofluoglu closed 9 months ago
Hi, @efeofluoglu. Thanks for reporting this.
Following your reproduction steps results in this error when I run npm test
:
> msw-mre@0.1.0 test
> TZ=UTC jest --all --watchAll=false --testResultsProcessor=jest-junit --coverage
- event [next-runtime-env] read environment variables prefixed with 'NEXT_PUBLIC_' from process.env.
- ready [next-runtime-env] wrote browser runtime environment variables to '/msw-2013/public/__ENV.js'.
Error: > Couldn't find any `pages` or `app` directory. Please create one under the project root
at findPagesDir (/msw-2013/node_modules/next/dist/lib/find-pages-dir.js:42:15)
at /msw-2013/node_modules/next/dist/build/jest/jest.js:116:75
at async readConfigFileAndSetRootDir (/msw-2013/node_modules/jest-config/build/readConfigFileAndSetRootDir.js:129:20)
at async readInitialOptions (/msw-2013/node_modules/jest-config/build/index.js:403:13)
at async readConfig (/msw-2013/node_modules/jest-config/build/index.js:147:48)
at async readConfigs (/msw-2013/node_modules/jest-config/build/index.js:424:26)
at async runCLI (/msw-2013/node_modules/@jest/core/build/cli/index.js:151:59)
at async Object.run (/msw-2013/node_modules/jest-cli/build/run.js:130:37)
Could you please resolve it and let me know? Thanks.
Prerequisites
Environment check
msw
versionBrowsers
No response
Reproduction repository
https://github.com/efeofluoglu/msw-mre
Reproduction steps
npm test
Current behavior
src/api/products/mocks
contain the mocks (data and the response handler) for theuse-my-products.test.ts
jest.config
andjest.setup
define the configuration for my test runner, jest. I define injest.setup.js
that jest should listen to mymswServer
defined insrc/api/msw-server
Here is the output from the test run:
The test fails because the expected responses dont match. The received response contains an empty array for
myProducts
even though I've specified the response data insrc/api/products/mocks
Expected behavior
The response data in test should have
myProducts
filled with the data that the handler uses