-
Notifications
You must be signed in to change notification settings - Fork 18
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
Alternative to loading svelte.config.js ? #6
Comments
Hey @nolanlawson I haven't dug in this issue completely, but to shed some light on why I made the library this way is because: Jest does not support async transformations at the moment, So I decided for the time being while we wait for Jest to support async transforms (there is a PR being worked on) to use I understand you want to pass the configuration directly but we can't right now, as soon as we can I'll make a PR for it :) |
In regards to the ES module error, do you have any proposed solution on how it could exist in a seperate file for the time being. Does simply supporting both |
I agree that this svelte config file is needed to provide options but I found no documentation on it nowhere. The only config I know for svelte is the rollup one, and I don't know how it relate to what's expected in svelte.config. I just jumped on the bandwagon of svelte testing and I struggle so much to find resources and correct configuration. |
@mihar-22 I didn't test it, but yes, it looks like supporting |
More details on that here: #25 |
have you tried this adding to you babel config file? |
@MikeProcudin I tried adding that to one of our new projects (which is having the same issue) and added that project as a dev dependency, and still get the same error. |
@wallw-bits , hey, I've changed svelte-jester to jest-transform-svelte and it worked for me. |
jest-transform-svelte doesn't support all the options from svelte-jester. But it might work, depending on your setup. |
It should be noted that this is not just a |
@nolanlawson Can you please retry with the latest version and jest 27+? Sveltekit requires ESM, so this should not be the problem anymore. |
Looks like I can set Thanks a bunch! |
Hi, thanks for writing
svelte-jester
, it seems like the best way to use Jest with Svelte! 🙂I noticed that, if a project's
package.json
declares"type": "module"
(new in Node 14), then when runningjest
it throws an error because it expects an ES module, not a CommonJS module. (See error below.)I know
svelte.config.js
is a convention borrowed fromsvelte-preprocessor
, but I wonder if there could be a way to pass the options directly intosvelte-jester
? This would eliminate the need to load a separate file. Alternatively, it seems that allowing a filename likesvelte.config.cjs
would also work.(Interestingly, changing
svelte.config.js
to use ES module format rather than CommonJS format throws the same error.)(FWIW, in case someone is googling this error and happens upon this GitHub issue, I worked around it by forking
svelte-jester
and avoiding loading the separate file.)The text was updated successfully, but these errors were encountered: