You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When calling jest.isolateModules in 2 different tests that each have await import('...') inside of them, the seconds seems effected by the execution of the first.
Run the 2 tests in the file: npm run test:unit -- -t 'index unit tests'
Observe the error:
$ npm run test:unit -- -t 'index unit tests'
> software-update-checker-cli@0.5.0 test:unit D:\Repos\software-update-checker-cli
> jest test/unit --collectCoverage --coverageDirectory=coverage/unit "-t" "index unit tests"
FAIL test/unit/index.unit.test.ts (7.23 s)
● Index Unit Tests › prints error and exits with unsuccessful code
expect(received).toEqual(expected) // deep equality
- Expected - 3
+ Received + 1
- Array [
- Array [],
- ]
+ Array []
21 | })
22 | await new Promise((resolve) => setTimeout(resolve, 0)) // need explicit sleep here because isolateModules does not await thrown error :/
> 23 | expect(homeSpy.mock.calls).toEqual([[]])
| ^
24 | // Not sure why there are 2 errors/exists...
25 | expect(consoleErrorSpy.mock.calls).toEqual([[error], [colors.red(error)]])
26 | expect(exitSpy.mock.calls).toEqual([[1], [1]])
at test/unit/index.unit.test.ts:23:32
at step (test/unit/index.unit.test.ts:52:23)
at Object.next (test/unit/index.unit.test.ts:33:53)
at fulfilled (test/unit/index.unit.test.ts:24:58)
Summary of all failing tests
FAIL test/unit/index.unit.test.ts (7.23 s)
● Index Unit Tests › prints error and exits with unsuccessful code
expect(received).toEqual(expected) // deep equality
- Expected - 3
+ Received + 1
- Array [
- Array [],
- ]
+ Array []
21 | })
22 | await new Promise((resolve) => setTimeout(resolve, 0)) // need explicit sleep here because isolateModules does not await thrown error :/
> 23 | expect(homeSpy.mock.calls).toEqual([[]])
| ^
24 | // Not sure why there are 2 errors/exists...
25 | expect(consoleErrorSpy.mock.calls).toEqual([[error], [colors.red(error)]])
26 | expect(exitSpy.mock.calls).toEqual([[1], [1]])
at test/unit/index.unit.test.ts:23:32
at step (test/unit/index.unit.test.ts:52:23)
at Object.next (test/unit/index.unit.test.ts:33:53)
at fulfilled (test/unit/index.unit.test.ts:24:58)
Test Suites: 1 failed, 24 skipped, 1 of 25 total
Tests: 1 failed, 333 skipped, 1 passed, 335 total
Snapshots: 0 total
Time: 8.45 s, estimated 11 s
Ran all test suites matching /test\\unit/i with tests matching "index unit tests".
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! software-update-checker-cli@0.5.0 test:unit: `jest test/unit --collectCoverage --coverageDirectory=coverage/unit "-t" "index unit tests"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the software-update-checker-cli@0.5.0 test:unit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
With the first test commented out, the second test runs fine. It seems that the first test running prevents the ../../src/index import from running again (because the mainMenu spy does not run the second time (when it should run each time the ../../src/index import is called).
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
🐛 Bug Report
When calling
jest.isolateModules
in 2 different tests that each haveawait import('...')
inside of them, the seconds seems effected by the execution of the first.To Reproduce
Steps to reproduce the behavior:
npm install
calls main menu
test in test/unit/index.unit.test.tsnpm run test:unit -- -t 'index unit tests'
Observe the error:
With the first test commented out, the second test runs fine. It seems that the first test running prevents the
../../src/index
import from running again (because themainMenu
spy does not run the second time (when it should run each time the../../src/index
import is called).envinfo
The text was updated successfully, but these errors were encountered: