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
With the `--pattern` flag available for the `test` and `start` commands, we can filter down which tests are being run. This is particularly useful when running tests in watch mode. This is probably more realistic than running `benmvp start` on the whole source code.
To continuously run all modes on all files (default behavior):
10
10
11
11
```js
12
12
import {start} from'@benmvp/cli'
13
13
14
14
start()
15
15
```
16
16
17
-
To run just type-checking:
17
+
To continuously run just type-checking on all files:
18
18
19
19
```js
20
20
import {start} from'@benmvp/cli'
@@ -24,7 +24,7 @@ start({
24
24
})
25
25
```
26
26
27
-
To run linting & unit tests:
27
+
To continuously run linting & unit tests on all files:
28
28
29
29
```sh
30
30
import {start} from '@benmvp/cli'
@@ -34,12 +34,39 @@ start({
34
34
})
35
35
```
36
36
37
-
## Type
37
+
To continuously run all modes only on files within `utils/` directories:
38
+
39
+
```js
40
+
import {test} from'@benmvp/cli'
41
+
42
+
start({
43
+
pattern:'utils/',
44
+
})
45
+
```
46
+
47
+
To continuously run just linting on files within `api/` directories:
48
+
49
+
```js
50
+
import {test} from'@benmvp/cli'
51
+
52
+
start({
53
+
modes: ['lint'],
54
+
pattern:'api/',
55
+
})
56
+
```
57
+
58
+
## Signature
38
59
39
60
`start()` has the following [TypeScript](https://www.typescriptlang.org/) signature:
40
61
41
62
```js
42
-
([options]: Options):Promise<Result>
63
+
type Mode ='type'|'lint'|'unit'
64
+
namespace TestOptions {
65
+
modes: Mode[];
66
+
pattern: string;
67
+
}
68
+
69
+
([options]: TestOptions):Promise<Result>
43
70
```
44
71
45
72
## Options
@@ -58,6 +85,12 @@ Optional. Defaults to all modes when unspecified.
58
85
59
86
> NOTE: [Jest Watch Plugins](https://jestjs.io/docs/en/watch-plugins) are added to make watch mode even more useful. Specifically the [eslint `watch-fix` plugin](https://github.com/jest-community/jest-runner-eslint#toggle---fix-in-watch-mode) is added to enable auto-fixing of lint errors. However, for this to work, `'lint'` has to be the first mode when specified.
60
87
88
+
### `pattern`
89
+
90
+
A regexp pattern string that is matched against all tests paths before executing the test.
Copy file name to clipboardExpand all lines: docs/cli/start.md
+21-3Lines changed: 21 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,24 +8,36 @@ Looking for Node API docs? View companion [`start()` documentation](../api/start
8
8
9
9
## Examples
10
10
11
-
To run all modes (default behavior):
11
+
To continuously run all modes on all files (default behavior):
12
12
13
13
```sh
14
14
benmvp start
15
15
```
16
16
17
-
To run just type-checking:
17
+
To continuously run just type-checking on all files:
18
18
19
19
```sh
20
20
benmvp start --modes type
21
21
```
22
22
23
-
To run linting & unit tests:
23
+
To continuously run linting & unit tests on all files:
24
24
25
25
```sh
26
26
benmvp start --modes lint unit
27
27
```
28
28
29
+
To continuously run all modes only on files within `utils/` directories:
30
+
31
+
```sh
32
+
benmvp start --pattern utils/
33
+
```
34
+
35
+
To continuously run just linting on files within `api/` directories:
36
+
37
+
```sh
38
+
benmvp start --modes lint --pattern api/
39
+
```
40
+
29
41
## Arguments
30
42
31
43
### `--modes`
@@ -40,6 +52,12 @@ Optional. Defaults to all modes.
40
52
41
53
> NOTE: [Jest Watch Plugins](https://jestjs.io/docs/en/watch-plugins) are added to make watch mode even more useful. Specifically the [eslint `watch-fix` plugin](https://github.com/jest-community/jest-runner-eslint#toggle---fix-in-watch-mode) is added to enable auto-fixing of lint errors. However, for this to work, `lint` has to be the first mode when specified.
42
54
55
+
### `--pattern`
56
+
57
+
A regexp pattern string that is matched against all tests paths before executing the test. Aliased as `-p`.
0 commit comments