Seems like other libraries won't working with preprocessors, won't maintained actively or didn't have proper licensing.
This library has peerDependencies
listings for svelte >= 3
.
npm install svelte-jester -D
Add the following to your Jest config
{
"transform": {
"^.+\\.svelte$": "svelte-jester"
},
"moduleFileExtensions": [
"js",
"svelte"
]
}
npm install @babel/core @babel/preset-env babel-jest -D
Add the following to your Jest config
"transform": {
"^.+\\.js$": "babel-jest",
"^.+\\.svelte$": "svelte-jester"
}
Create a .babelrc
and add the following
{
"presets": [["@babel/preset-env", { "targets": { "node": "current" } }]]
}
Preprocessors are loaded from svelte.config.js
.
Add the following to your Jest config
"transform": {
"^.+\\.js$": "babel-jest",
"^.+\\.svelte$": ["svelte-jester", { "preprocess": true }]
}
Create a svelte.config.js
file and configure it, see
svelte-preprocess for more information.
preprocess
(default: false): Pass in true
if you are using Svelte preprocessors.
They are loaded from svelte.config.js
.
debug
(default: false): If you'd like to see the output of the compiled code then pass in true
.
compilerOptions
(default: {}): Use this to pass in
Svelte compiler options.
"transform": {
"^.+\\.js$": "babel-jest",
"^.+\\.svelte$": ["svelte-jester", {
"preprocess": false,
"debug": false,
"compilerOptions": {}
}]
}
This package is required when using Svelte with the Testing Library. If you'd like to avoid including implementation details in your tests, and making them more maintainble in the long run, then consider checking out @testing-library/svelte.
Thanks to all contributors, inspired by: