diff --git a/apps/docs-app/docs/features/testing/overview.md b/apps/docs-app/docs/features/testing/overview.md index 461ec3534..95f2cca00 100644 --- a/apps/docs-app/docs/features/testing/overview.md +++ b/apps/docs-app/docs/features/testing/overview.md @@ -50,6 +50,10 @@ pnpm run test You can also [add Vitest](/docs/features/testing/vitest) to your existing project. +## IDE Support + +Tests can also be run directly from your IDE using the Vitest [IDE integrations](https://vitest.dev/guide/ide) for VS Code or JetBrains IDEs. + ## Known limitations - Only globals are patched with Zone.js. This means, that if you import `it`, `describe` etc from `vitest` directly, you won't be able to run `fakeAsync`. Instead, use the functions (`it`, `describe` etc. the way you used to do in Jest/Jasmine – without any imports of these functions in the test file). diff --git a/apps/docs-app/docs/features/testing/vitest.md b/apps/docs-app/docs/features/testing/vitest.md index 2f84c7e67..e97f6e977 100644 --- a/apps/docs-app/docs/features/testing/vitest.md +++ b/apps/docs-app/docs/features/testing/vitest.md @@ -107,6 +107,7 @@ Next, define a `src/test-setup.ts` file to setup the `TestBed`: If you are using `Zone.js` for change detection, import the `setup-zone` script. This script automatically includes support for setting up snapshot tests. ```ts +import '@angular/compiler'; import '@analogjs/vitest-angular/setup-zone'; import { @@ -126,6 +127,7 @@ getTestBed().initTestEnvironment( If you are using `Zoneless` change detection, use the following setup: ```ts +import '@angular/compiler'; import '@analogjs/vitest-angular/setup-snapshots'; import { provideZonelessChangeDetection, NgModule } from '@angular/core'; @@ -171,14 +173,14 @@ Next, update the `test` target in the `angular.json` to use the `@analogjs/vites > You can also add a new target and name it `vitest` to run alongside your `test` target. -Lastly, add the `src/test-setup.ts` to `files` array in the `tsconfig.spec.json` in the root of your project, set the `target` to `es2016`, and update the `types`. +Lastly, add the `src/test-setup.ts` to `files` array in the `tsconfig.spec.json` in the root of your project, set the `target` to `es2022`, and update the `types`. ```json { "extends": "./tsconfig.json", "compilerOptions": { "outDir": "./out-tsc/spec", - "target": "es2016", + "target": "es2022", "types": ["vitest/globals", "node"] }, "files": ["src/test-setup.ts"], @@ -255,24 +257,6 @@ export default defineConfig(({ mode }) => ({ })); ``` -Next, add the `@angular/compiler` import to the `src/test-setup.ts` file. - -```ts -import '@angular/compiler'; -import '@analogjs/vitest-angular/setup-zone'; - -import { - BrowserTestingModule, - platformBrowserTesting, -} from '@angular/platform-browser/testing'; -import { getTestBed } from '@angular/core/testing'; - -getTestBed().initTestEnvironment( - BrowserTestingModule, - platformBrowserTesting(), -); -``` - ## Running Tests To run unit tests, use the `test` command: