-
Notifications
You must be signed in to change notification settings - Fork 5
svelte-jester 2.x does not work #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I can confirm the issue: steps to reproduce npm init svelte@next svelte-jest-add-js
cd svelte-jest-add-js/
npx apply rossyman/svelte-add-jest
pnpm install
pnpm test
> ~[email protected] test /home/sas/devel/apps/glas-it/apps/wingback/learn/svelte-jest-add-js
> jest src --config jest.config.json
FAIL src/routes/index.spec.js
● Test suite failed to run
Jest: synchronous transformer /home/sas/devel/apps/glas-it/apps/wingback/learn/svelte-jest-add-js/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/svelte-jester/dist/transformer.cjs must export a "process" function.
at invariant (node_modules/.pnpm/@[email protected]/node_modules/@jest/transform/build/ScriptTransformer.js:1092:11)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.67 s, estimated 1 s
Ran all test suites matching /src/i.
ERROR Test failed. See above for more details. Workaround: pnpm install -D [email protected] [email protected] Using typescript just have to also add ts-jest pnpm install -D [email protected] [email protected] [email protected] |
I got it to work in ESM mode with the following changes per the docs:
The test was then failing unrelated to the |
Forgive if I'm missing the obvious, I'm fairly new to most of this. @benmccann's suggestion does get past some issues, but it doesn't get me all the way there. I don't think this issue is the same as the one addressed by using Starting with a clean project like @opensas above, with the following choices for the
And this for the
And supplying
Tried some workarounds for this but no luck. Of course, version rollback works fine. |
You must have messed something up. I'm not sure what. But I pushed a working example of a project using |
thanks, @benmccann Indeed this works fine! Yup. very likely I did mess something up. I see, your minimal example was The minimal change to break things the way I did is to use typescript, and then make your changes. Should I not have expected TS support to work? Maybe some extra steps I should have taken? |
I didn't try with TypeScript. I sent svelteness/svelte-jester#71 to fix the CJS support though |
Investigating now -- v27 did seem to change the way the environment is setup and how imports work -- Going to see how the adder can accommodate these changes. |
Looked into the TypeScript issue, and I've managed to fix it with a little extra configuration, after following the steps outlined by @benmccann further up: /**
* Modify your jest.config.json to include the following:
*/
"transform": {
/** Other transformers here ... */
"^.+\\.svelte$": [
"./node_modules/svelte-jester/dist/transformer.mjs",
{
"preprocess": true
}
],
},
"extensionsToTreatAsEsm": [
".ts",
".svelte"
],
"globals": {
"ts-jest": {
"tsconfig": "tsconfig.spec.json",
"useESM": true
}
} For whatever reason, even when running with the ESM flag enabled via |
svelte-jester 2.x does not work with jest 27, see svelteness/svelte-jester#65
Solution: Downgrade to
"ts-jest": "26.5.6",
"jest": "26.6.3",
"svelte-jester": "1.8.2",
The text was updated successfully, but these errors were encountered: