Cannot use Jest / TS / React without duplicating and renaming required config #2952
Replies: 1 comment 4 replies
-
If you look at this line here, you can see that the You can disable that and safely remove the // jest.config.js
module.exports = {
...require('@snowpack/app-scripts-preact/jest.config.js')(),
setupFilesAfterEnv: [],
}; From my testing, I don't think app-scrips-preact is even needed, as this config also works without issues after installing // jest.config.js
module.exports = {
preset: 'ts-jest',
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
}; As far as I can see, the preset from the guide you linked adds some transformers for things like CSS imports, but those could likely be handled manually with a module name mapper. Hope this helps. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello.
This question is in reference to documentation here: https://www.snowpack.dev/guides/jest
I used the
app-template-react-typescript
to set up a simple starter project, and wanted to be able to run some tests with Jest and testing-library. I got everything set up as I thought I should, and could not get my tests to handle TS and JSX.I had installed
@snowpack/app-scripts-react
and was simply copying and pasting the example starter config to my project root.After a lot of fumbling around and looking at the core configs, I thought maybe I should try renaming the required, root-level config file from
jest.setup.js
tojest.config.js
. I kept both for a moment, found my setup was suddenly working, then deleted thejest.setup.js
and found I'd broken things again. So now I find my Jest setup works as expected only when I have the same (default) configuration file in my project root, once namedjest.setup.js
and once namedjest.config.js
.I am submitting this as a troubleshooting issue after closing a PR, #2951, since simply renaming this config isn't the solution, and I'm not sure what's going on.
Thanks for any feedback.
Beta Was this translation helpful? Give feedback.
All reactions