Skip to content

Commit d1b1498

Browse files
authored
Merge pull request testing-library#293 from mihar-22/svelte
docs(svelte): simplify setup guide by removing babel
2 parents da0d581 + 835f16a commit d1b1498

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

docs/svelte-testing-library/example.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import '@testing-library/jest-dom/extend-expect'
3030

3131
import { render, fireEvent } from '@testing-library/svelte'
3232

33-
import Comp from '../Comp.svelte'
33+
import Comp from '../Comp'
3434

3535
test('shows proper heading when rendered', () => {
3636
const { getByText } = render(Comp, { props: { name: 'World' } })

docs/svelte-testing-library/setup.md

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ with any testing framework and runner you're comfortable with.
99

1010
## Jest
1111

12-
1. Install Jest and Babel
12+
1. Install Jest
1313

1414
```
15-
npm install --save-dev jest babel-jest @babel/core @babel/preset-env
15+
npm install --save-dev jest
1616
```
1717
1818
2. Add the following to your `package.json`
@@ -26,55 +26,46 @@ with any testing framework and runner you're comfortable with.
2626
}
2727
```
2828
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
3830
we need to install
3931
[jest-transform-svelte](https://github.com/rspieker/jest-transform-svelte)
4032
4133
```
4234
npm install --save-dev jest-transform-svelte
4335
```
4436
45-
5. Add the following Jest configuration to your `package.json`
37+
4. Add the following Jest configuration to your `package.json`
4638
4739
```json
4840
{
4941
"jest": {
5042
"transform": {
51-
"^.+\\.js$": "babel-jest",
5243
"^.+\\.svelte$": "jest-transform-svelte"
5344
},
54-
"moduleFileExtensions": ["js", "json", "svelte"]
45+
"moduleFileExtensions": ["js", "svelte"]
5546
}
5647
}
5748
```
5849
59-
6. This is optional but it is recommended, you can install
50+
5. This is optional but it is recommended, you can install
6051
[jest-dom](https://github.com/testing-library/jest-dom) to add handy
6152
assertions to Jest
6253
63-
6.1 Install jest-dom
54+
5.1 Install jest-dom
6455
6556
```
6657
npm install --save-dev @testing-library/jest-dom
6758
```
6859
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`
7061
7162
```json
7263
{
7364
"setupFilesAfterEnv": ["@testing-library/jest-dom/extend-expect"]
7465
}
7566
```
7667
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)
7869
and run it
7970
8071
```

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy