-
-
Notifications
You must be signed in to change notification settings - Fork 298
Description
Please provide the environment you discovered this bug in.
System:
OS: Windows 11 10.0.22631
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Memory: 2.98 GB / 15.85 GB
Binaries:
Node: 20.13.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.22 - ~\AppData\Roaming\npm\yarn.CMD
npm: 10.9.0 - C:\Program Files\nodejs\npm.CMD
pnpm: 9.12.2 - ~\AppData\Local\pnpm\pnpm.EXE
Browsers:
Edge: Chromium (131.0.2903.112)
Internet Explorer: 11.0.22621.3527
npmPackages:
@analogjs/vitest-angular: ^1.14.0 => 1.14.0Which area/package is the issue in?
vitest-angular
Description
I have an existing open source project Angular-Slickgrid that I wanted to migrate from Jest to Analog/Vitest and while looking at how to do that, I found and followed this great article Faster testing with Angular and Vitest and ran this command
ng g @analogjs/platform:setup-vitest --project [your-project-name]which worked for the most part (with some adjustments here and there), but I kept having this error
it turns out that there's a very small missing step in the script, it does create the necessary setup file ./src/test-setup.ts but it's missing the step to update the tsconfig.spec.json to add the following change "files": ["src/test-setup.ts"] and it took me a while to understand the problem. I found the missing change while reading the entire Analog/Vitest docs, so the docs has the step but the script is missing the step.
In the end, I did manage to complete the migration from Jest to Analog/Vitest in my project PR, the change I'm asking is to help new users other than me.
Please provide the exception or error you saw
Error: Need to call TestBed.initTestEnvironment() first
Other information
I simply ask for the script to be updated and add the missing step to update the tsconfig.spec.json file and add the following change "files": ["src/test-setup.ts"] to avoid spending too much time for new users on debugging like I did.
Here's the docs that does include the step missing in the script
I would be willing to submit a PR to fix this issue
- Yes
- No
