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
Copy file name to clipboardExpand all lines: 05-testing/01-react/01-base/01-config/README.md
+95-49Lines changed: 95 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,15 @@
1
1
# 01 Config
2
2
3
-
In this example we are going to add a basic setup needed to support unit testing with Jest.
3
+
In this example we are going to add a basic setup needed to support unit testing with Vitest.
4
4
5
5
We will start from `00-boilerplate`.
6
6
7
7
Summary steps:
8
8
9
-
- Install `jest`.
9
+
- Install `vitest`.
10
10
- Add configuration.
11
11
- Add dummy spec.
12
-
- External jest config file.
12
+
- External vitest config file.
13
13
14
14
# Steps to build it
15
15
@@ -21,40 +21,32 @@ npm install
21
21
22
22
# Libraries
23
23
24
-
- We are going to install the main library which we base all our unit tests, [Jest](https://facebook.github.io/jest/en/).
24
+
- We are going to install the main library which we base all our unit tests, [Vitest](https://vitest.dev/).
25
25
26
-
-[jest](https://github.com/facebook/jest): JavaScript Testing library with runner, assertion, mocks, etc.
27
-
-[@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/df38f202a0185eadfb6012e47dd91f8975eb6151/types/jest): Typings for jest.
26
+
-[vitest](https://github.com/vitest-dev/vitest): JavaScript Testing library with runner, assertion, mocks, etc.
27
+
28
+
> Jest it's a good option for React projects, but it doesn't support [ECMAScript Modules](https://jestjs.io/docs/ecmascript-modules) yet.
29
+
>
30
+
> [Migration from Jest](https://vitest.dev/guide/migration.html#migrating-from-jest)
28
31
29
32
```bash
30
-
npm install jest @types/jest --save-dev
33
+
npm install vitest --save-dev
31
34
```
32
35
33
-
> If we are using `@babel/preset-typescript` it is not necessary install [ts-jest](https://github.com/kulshekhar/ts-jest): A preprocessor with sourcemap support to help use TypeScript with Jest.
-`npm test`: it will run all specs in watch mode (by default). But it depends on the [process.env.CI](https://vitest.dev/config/#watch)
48
40
49
-
> --watchAll To rerun all tests.
50
-
51
-
> --watch To rerun tests related to changed files.
52
-
53
-
> --verbose Display individual test results with the test suite hierarchy.
54
-
55
-
> -i or --runInBand Run all tests serially in the current process, rather than creating a worker pool of child processes that run tests. This can be useful for debugging
0 commit comments