Replies: 2 comments 3 replies
-
If you have a "test" in package.json, you can set |
Beta Was this translation helpful? Give feedback.
-
Im having a similar issue. Hopefully it's not 'hijacking' your thread OP. The fix feels a little hack-y so if anyone has advice I appreciate it but here's how I solved it. First, adding import 'jest-preset-angular/setup-jest' to the top of my However when I do that tests fail when running just plain ● Test suite failed to run
Cannot set base providers because it has already been called
1 | import { jest } from '@jest/globals'
> 2 | import 'jest-preset-angular/setup-jest'; One difference from you OP is I dont have See https://stackoverflow.com/questions/69882564/jest-error-cannot-set-base-providers-after-angular-v13-upgrade-using-ng-test/73825433#73825433 but solution there left me in the same place, tests either work using vscode-jest or CLI but not both... So in the end I put condition around the above import, e.g. in if (process.env.NODE_ENV === 'test') {
require('jest-preset-angular/setup-jest')
} and things work in both places: Test Suites: 26 passed, 26 total
Tests: 140 passed, 140 total
Snapshots: 0 total
Time: 4.678 s
Ran all test suites. including those glorious green checks: TBH, find this stuff pretty confusing, appreciate any help! |
Beta Was this translation helpful? Give feedback.
-
I can run all tests fine via command line
npx ng test
.Running any single test I get an error like this
and then later
jest.config.js contents:
Again, the tests run fine via npx ng test, but running via the extension always fails. I haven't configured any extension settings from the default.
Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions