Skip to content

Commit 5fdb141

Browse files
Merge branch 'master' into dependabot/npm_and_yarn/babel-jest-29.6.2
2 parents abc8159 + d44a0d8 commit 5fdb141

File tree

2 files changed

+351
-168
lines changed

2 files changed

+351
-168
lines changed

README.md

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Add the following to your Jest config:
8585
```json
8686
{
8787
"transform": {
88-
"^.+\\.svelte$": "svelte-jester/dist/transformer.cjs"
88+
"^.+\\.svelte$": "./node_modules/svelte-jester/dist/transformer.cjs"
8989
},
9090
"moduleFileExtensions": ["js", "svelte"]
9191
}
@@ -126,47 +126,47 @@ To enable TypeScript support you'll need to setup [`svelte-preprocess`](https://
126126

127127
1. Create a `svelte.config.js` at the root of your project:
128128

129-
```js
130-
import preprocess from 'svelte-preprocess'
129+
```js
130+
import preprocess from 'svelte-preprocess'
131131

132-
/** @type {import('@sveltejs/kit').Config} */
133-
export default config = {
134-
preprocess: preprocess(),
135-
// ...
136-
};
137-
```
132+
/** @type {import('@sveltejs/kit').Config} */
133+
export default config = {
134+
preprocess: preprocess(),
135+
// ...
136+
};
137+
```
138138

139139
To learn what options you can pass to `sveltePreprocess`, please refer to the [documentation](https://github.com/sveltejs/svelte-preprocess/blob/main/docs/preprocessing.md#typescript).
140140

141141
1. In your Jest config, enable preprocessing for `svelte-jester`, and add `ts-jest` as a transform:
142142

143-
```json
144-
"transform": {
145-
"^.+\\.svelte$": [
146-
"svelte-jester",
147-
{
148-
"preprocess": true
149-
}
150-
],
151-
"^.+\\.ts$": [
152-
"ts-jest",
153-
{
154-
"useESM": true
155-
// optional: seperate tsconfig for tests
156-
//"tsconfig": "tsconfig.spec.json",
157-
}
158-
],
159-
},
160-
"moduleFileExtensions": [
161-
"js",
162-
"ts",
163-
"svelte"
164-
],
165-
"extensionsToTreatAsEsm": [
166-
".svelte",
167-
".ts"
168-
],
169-
```
143+
```json
144+
"transform": {
145+
"^.+\\.svelte$": [
146+
"svelte-jester",
147+
{
148+
"preprocess": true
149+
}
150+
],
151+
"^.+\\.ts$": [
152+
"ts-jest",
153+
{
154+
"useESM": true
155+
// optional: seperate tsconfig for tests
156+
//"tsconfig": "tsconfig.spec.json",
157+
}
158+
],
159+
},
160+
"moduleFileExtensions": [
161+
"js",
162+
"ts",
163+
"svelte"
164+
],
165+
"extensionsToTreatAsEsm": [
166+
".svelte",
167+
".ts"
168+
],
169+
```
170170

171171
However if you do not want to create a `svelte.config.js` at the root of your
172172
project or you wish to use a custom config just for tests, you may pass the
@@ -218,22 +218,22 @@ path to the config file to the `preprocess` option thus:
218218

219219
1. In your Jest config, enable preprocessing for `svelte-jester`, and add `ts-jest` as a transform:
220220

221-
```json
222-
"transform": {
223-
"^.+\\.svelte$": [
224-
"svelte-jester/dist/transformer.cjs",
225-
{
226-
"preprocess": true
227-
}
228-
],
229-
"^.+\\.ts$": "ts-jest"
230-
},
231-
"moduleFileExtensions": [
232-
"js",
233-
"ts",
234-
"svelte"
235-
]
236-
```
221+
```json
222+
"transform": {
223+
"^.+\\.svelte$": [
224+
"./node_modules/svelte-jester/dist/transformer.cjs",
225+
{
226+
"preprocess": true
227+
}
228+
],
229+
"^.+\\.ts$": "ts-jest"
230+
},
231+
"moduleFileExtensions": [
232+
"js",
233+
"ts",
234+
"svelte"
235+
]
236+
```
237237

238238
However if you do not want to create a `svelte.config.js` at the root of your
239239
project or you wish to use a custom config just for tests, you may pass the
@@ -242,7 +242,7 @@ path to the config file to the `preprocess` option thus:
242242
```json
243243
"transform": {
244244
"^.+\\.svelte$": [
245-
"svelte-jester/dist/transformer.cjs",
245+
"./node_modules/svelte-jester/dist/transformer.cjs",
246246
{
247247
"preprocess": "/some/path/to/svelte.config.js"
248248
}
@@ -273,7 +273,7 @@ Add the following to your Jest config:
273273
}
274274
```
275275

276-
For CJS, replace `"svelte-jester"` with `"svelte-jester/dist/transformer.cjs"`.
276+
For CJS, replace `"svelte-jester"` with `"./node_modules/svelte-jester/dist/transformer.cjs"`.
277277

278278
Create a `svelte.config.js` file and configure it, see
279279
[svelte-preprocess](https://github.com/kaisermann/svelte-preprocess) for more information.
@@ -313,7 +313,7 @@ When `upward` is set it will stop at the first config file it finds above the fi
313313
```json
314314
"transform": {
315315
"^.+\\.js$": "babel-jest",
316-
"^.+\\.svelte$": ["svelte-jester/dist/transformer.cjs", {
316+
"^.+\\.svelte$": ["./node_modules/svelte-jester/dist/transformer.cjs", {
317317
"preprocess": false,
318318
"debug": false,
319319
"compilerOptions": {},
@@ -347,4 +347,4 @@ Thanks to all contributors, inspired by:
347347
[version-badge]: https://img.shields.io/npm/v/svelte-jester
348348
[license]: https://github.com/svelteness/svelte-jester/blob/main/LICENSE
349349
[license-badge]: https://img.shields.io/github/license/svelteness/svelte-jester?color=b
350-
<!-- prettier-ignore-end -->
350+
<!-- prettier-ignore-end -->

0 commit comments

Comments
 (0)