Skip to content

Commit

Permalink
Get Jest working
Browse files Browse the repository at this point in the history
  • Loading branch information
MaddyGuthridge committed May 19, 2024
1 parent bdc0e2c commit 7c6584b
Show file tree
Hide file tree
Showing 7 changed files with 9,242 additions and 1,798 deletions.
12 changes: 12 additions & 0 deletions babel.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current'
},
},
],
],
}
33 changes: 33 additions & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module.exports = {
setupFilesAfterEnv: [
"jest-extended/all"
],
maxWorkers: 1,
transform: {
"^.+\\.svelte$": [
"svelte-jester",
{
preprocess: true
}
],
"^.+\\.js$": "babel-jest",
// https://github.com/kulshekhar/ts-jest/issues/4081#issuecomment-1515758013
"^.+\\.ts$": ["ts-jest", { tsconfig: './tsconfig.jest.json' }],
},
testEnvironment: "jsdom",
moduleFileExtensions: [
"js",
"ts",
"svelte"
],
// https://koenvg.medium.com/setting-up-jest-with-sveltekit-4f0a0e379668#3f2e
moduleNameMapper: {
'^\\$lib(.*)$': '<rootDir>/src/lib$1',
'^\\$types(.*)$': '<rootDir>/src/types$1',
'^\\$components(.*)$': '<rootDir>/src/components$1',
'^\\$app(.*)$': [
'<rootDir>/.svelte-kit/dev/runtime/app$1',
'<rootDir>/.svelte-kit/build/runtime/app$1'
]
}
};
Loading

0 comments on commit 7c6584b

Please sign in to comment.