Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 56 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Add the following to your Jest config:
```json
{
"transform": {
"^.+\\.svelte$": "svelte-jester/dist/transformer.cjs"
"^.+\\.svelte$": "./node_modules/svelte-jester/dist/transformer.cjs"
},
"moduleFileExtensions": ["js", "svelte"]
}
Expand Down Expand Up @@ -126,47 +126,47 @@ To enable TypeScript support you'll need to setup [`svelte-preprocess`](https://

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

```js
import preprocess from 'svelte-preprocess'
```js
import preprocess from 'svelte-preprocess'

/** @type {import('@sveltejs/kit').Config} */
export default config = {
preprocess: preprocess(),
// ...
};
```
/** @type {import('@sveltejs/kit').Config} */
export default config = {
preprocess: preprocess(),
// ...
};
```

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).

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

```json
"transform": {
"^.+\\.svelte$": [
"svelte-jester",
{
"preprocess": true
}
],
"^.+\\.ts$": [
"ts-jest",
{
"useESM": true
// optional: seperate tsconfig for tests
//"tsconfig": "tsconfig.spec.json",
}
],
},
"moduleFileExtensions": [
"js",
"ts",
"svelte"
],
"extensionsToTreatAsEsm": [
".svelte",
".ts"
],
```
```json
"transform": {
"^.+\\.svelte$": [
"svelte-jester",
{
"preprocess": true
}
],
"^.+\\.ts$": [
"ts-jest",
{
"useESM": true
// optional: seperate tsconfig for tests
//"tsconfig": "tsconfig.spec.json",
}
],
},
"moduleFileExtensions": [
"js",
"ts",
"svelte"
],
"extensionsToTreatAsEsm": [
".svelte",
".ts"
],
```

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

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

```json
"transform": {
"^.+\\.svelte$": [
"svelte-jester/dist/transformer.cjs",
{
"preprocess": true
}
],
"^.+\\.ts$": "ts-jest"
},
"moduleFileExtensions": [
"js",
"ts",
"svelte"
]
```
```json
"transform": {
"^.+\\.svelte$": [
"./node_modules/svelte-jester/dist/transformer.cjs",
{
"preprocess": true
}
],
"^.+\\.ts$": "ts-jest"
},
"moduleFileExtensions": [
"js",
"ts",
"svelte"
]
```

However if you do not want to create a `svelte.config.js` at the root of your
project or you wish to use a custom config just for tests, you may pass the
Expand All @@ -242,7 +242,7 @@ path to the config file to the `preprocess` option thus:
```json
"transform": {
"^.+\\.svelte$": [
"svelte-jester/dist/transformer.cjs",
"./node_modules/svelte-jester/dist/transformer.cjs",
{
"preprocess": "/some/path/to/svelte.config.js"
}
Expand Down Expand Up @@ -273,7 +273,7 @@ Add the following to your Jest config:
}
```

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

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