Skip to content

Instantly share code, notes, and snippets.

@nathansmith
Last active September 27, 2022 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathansmith/cbd35fd5ed10868cf41d689181dbd477 to your computer and use it in GitHub Desktop.
Save nathansmith/cbd35fd5ed10868cf41d689181dbd477 to your computer and use it in GitHub Desktop.
Jest test setup
require('@testing-library/jest-dom');
// Override.
Object.defineProperty(window, 'requestAnimationFrame', {
writable: true,
value: (f) => {
if (typeof f === 'function') {
f();
}
},
});
{
"jest": {
"moduleFileExtensions": [
"js",
"svelte",
"ts"
],
"setupFilesAfterEnv": [
"<rootDir>/scripts/test-setup.js"
],
"testEnvironment": "jsdom",
"transform": {
"^.+\\.svelte$": [
"svelte-jester",
{
"preprocess": true
}
],
"^.+\\.ts$": "ts-jest",
"^.+\\.js$": "babel-jest"
},
"transformIgnorePatterns": [
"<rootDir>/node_modules/lodash-es"
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment