I am running jest test suites for a Next.js app that uses Redux Toolkit. I'm using msw to mock any necessary calls to another api outside of the Next app that are handled by Redux Toolkit.
I have not mocked ALL of the RTK query endpoints, only the ones which I am currently using in my tests.
The tests run fine when I'm running without coverage generation via npm run test.
However, when I run with coverage reports via npm run test -- --coverage, all tests fail and they all have the same error:
- Test suite failed to run
No element indexed by 9
at ArraySet_at [as at] (node_modules/source-map-support/node_modules/source-map/lib/array-set.js:109:9)
at BasicSourceMapConsumer.SourceMapConsumer_originalPositionFor [as originalPositionFor] (node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:673:30)
at mapSourcePosition (node_modules/source-map-support/source-map-support.js:214:42)
at wrapCallSite (node_modules/source-map-support/source-map-support.js:358:20)
at node_modules/source-map-support/source-map-support.js:399:26
at Array.map (<anonymous>)
at Function.prepareStackTrace (node_modules/source-map-support/source-map-support.js:398:30)
I found that if I set the msw handlers to an empty array, the error doesn't appear. The few tests which require the API fail, as expected. However, the tests all run fine otherwise.
I'm unsure where to go from here. Any advice is greatly appreciated.
I am running jest test suites for a Next.js app that uses Redux Toolkit. I'm using msw to mock any necessary calls to another api outside of the Next app that are handled by Redux Toolkit.
I have not mocked ALL of the RTK query endpoints, only the ones which I am currently using in my tests.
The tests run fine when I'm running without coverage generation via
npm run test
.However, when I run with coverage reports via
npm run test -- --coverage
, all tests fail and they all have the same error:I found that if I set the msw handlers to an empty array, the error doesn't appear. The few tests which require the API fail, as expected. However, the tests all run fine otherwise.
I'm unsure where to go from here. Any advice is greatly appreciated.