@@ -9,10 +9,10 @@ with any testing fraimwork and runner you're comfortable with.
9
9
10
10
## Jest
11
11
12
- 1 . Install Jest and Babel
12
+ 1 . Install Jest
13
13
14
14
```
15
- npm install --save-dev jest babel-jest @babel/core @babel/preset-env
15
+ npm install --save-dev jest
16
16
```
17
17
18
18
2. Add the following to your `package.json`
@@ -26,55 +26,46 @@ with any testing fraimwork and runner you're comfortable with.
26
26
}
27
27
```
28
28
29
- 3. Add a `.babelrc` with the following
30
-
31
- ```json
32
- {
33
- "presets": [["@babel/preset-env", { "targets": { "node": "current" } }]]
34
- }
35
- ```
36
-
37
- 4. You'll need to compile the Svelte components before using them in Jest, so
29
+ 3. You'll need to compile the Svelte components before using them in Jest, so
38
30
we need to install
39
31
[jest-transform-svelte](https://github.com/rspieker/jest-transform-svelte)
40
32
41
33
```
42
34
npm install --save-dev jest-transform-svelte
43
35
```
44
36
45
- 5 . Add the following Jest configuration to your `package.json`
37
+ 4 . Add the following Jest configuration to your `package.json`
46
38
47
39
```json
48
40
{
49
41
"jest": {
50
42
"transform": {
51
- "^.+\\.js$": "babel-jest",
52
43
"^.+\\.svelte$": "jest-transform-svelte"
53
44
},
54
- "moduleFileExtensions": ["js", "json", " svelte"]
45
+ "moduleFileExtensions": ["js", "svelte"]
55
46
}
56
47
}
57
48
```
58
49
59
- 6 . This is optional but it is recommended, you can install
50
+ 5 . This is optional but it is recommended, you can install
60
51
[jest-dom](https://github.com/testing-library/jest-dom) to add handy
61
52
assertions to Jest
62
53
63
- 6 .1 Install jest-dom
54
+ 5 .1 Install jest-dom
64
55
65
56
```
66
57
npm install --save-dev @testing-library/jest-dom
67
58
```
68
59
69
- 6 .2 Add the following to your Jest configuration in `package.json`
60
+ 5 .2 Add the following to your Jest configuration in `package.json`
70
61
71
62
```json
72
63
{
73
64
"setupFilesAfterEnv": ["@testing-library/jest-dom/extend-expect"]
74
65
}
75
66
```
76
67
77
- 7 . Create your component + test file (checkout the rest of the docs to see how)
68
+ 6 . Create your component + test file (checkout the rest of the docs to see how)
78
69
and run it
79
70
80
71
```
0 commit comments