-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
436 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
`project.json`: | ||
|
||
```json | ||
//... | ||
"my-app": { | ||
"targets": { | ||
//... | ||
"test": { | ||
"executor": "@nrwl/vite:test", | ||
//... | ||
//... | ||
"options": { | ||
"config": "apps/my-app/vite.config.ts" | ||
} | ||
//... | ||
} | ||
} | ||
} | ||
``` | ||
|
||
```bash | ||
nx test my-app | ||
``` | ||
|
||
## Examples | ||
|
||
{% tabs %} | ||
|
||
{% tab label="Running in watch mode" %} | ||
To run testing in watch mode, you can create a new configuration within your test target, and have watch set to true. For example: | ||
|
||
```json | ||
"my-app": { | ||
"targets": { | ||
//... | ||
"test": { | ||
"executor": "@nrwl/vite:test", | ||
//... | ||
//... | ||
"options": { | ||
"config": "apps/my-app/vite.config.ts" | ||
}, | ||
"configurations": { | ||
"watch": { | ||
"watch": true | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
And then run `nx run my-app:test:watch`. | ||
|
||
Alternatively, you can just run the default test target with the `--watch` flag preset, like so: | ||
|
||
```bash | ||
nx run my-app:test --watch | ||
``` | ||
|
||
{% /tab %} | ||
{% tab label="Updating snapshots" %} | ||
Whenever a test fails because of an outdated snapshot, you can tell vitest to update them with the following: | ||
|
||
```bash | ||
nx run my-app:test -u | ||
``` | ||
|
||
{% /tab %} | ||
|
||
{% /tabs %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { convertNxExecutor } from '@nrwl/devkit'; | ||
import vitestExecutor from './vitest.impl'; | ||
|
||
export default convertNxExecutor(vitestExecutor); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export interface VitestExecutorSchema { | ||
config: string; | ||
passWithNoTests: boolean; | ||
testNamePattern?: string; | ||
mode: 'test' | 'benchmark' | 'typecheck'; | ||
reporters?: string[]; | ||
watch: boolean; | ||
update: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema", | ||
"version": 2, | ||
"cli": "nx", | ||
"title": "Vitest executor", | ||
"description": "Test using Vitest.", | ||
"type": "object", | ||
"properties": { | ||
"config": { | ||
"type": "string", | ||
"description": "The path to the local vitest config", | ||
"x-completion-type": "file", | ||
"x-completion-glob": "@(vitest|vite).config@(.js|.ts)" | ||
}, | ||
"passWithNoTests": { | ||
"type": "boolean", | ||
"default": true, | ||
"description": "Pass the test even if no tests are found" | ||
}, | ||
"testNamePattern": { | ||
"type": "string", | ||
"description": "Run tests with full names matching the pattern" | ||
}, | ||
"mode": { | ||
"type": "string", | ||
"enum": ["test", "benchmark", "typecheck"], | ||
"default": "test", | ||
"description": "The mode that vitest will run on" | ||
}, | ||
"watch": { | ||
"type": "boolean", | ||
"default": false, | ||
"description": "Enable watch mode" | ||
}, | ||
"reporters": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
}, | ||
"description": "An array of reporters to pass to vitest" | ||
}, | ||
"update": { | ||
"type": "boolean", | ||
"default": false, | ||
"alias": "u", | ||
"description": "Update snapshots" | ||
}, | ||
"coverage": { | ||
"type": "boolean", | ||
"default": false, | ||
"description": "Enable coverage report" | ||
} | ||
}, | ||
"required": [], | ||
"examplesFile": "../../../docs/test-examples.md" | ||
} |
Oops, something went wrong.
54670c9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nx-dev – ./
nx-dev-nrwl.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx.dev
nx-five.vercel.app