svelte-jester: TypeError [ERR_INVALID_ARG_TYPE]
Having trouble running tests, here’s a demo repo.
I’m using it with SvelteKit and pnpm on Windows 10.
PS D:\Projects\svelte-component-template> pnpm test
> ~TODO~@0.0.1 test D:\Projects\svelte-component-template
> cross-env NODE_OPTIONS=--experimental-vm-modules jest src --config jest.config.json
(node:25868) ExperimentalWarning: VM Modules is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:28608) ExperimentalWarning: VM Modules is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:38792) ExperimentalWarning: VM Modules is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
FAIL src/lib/first/First.test.js
● Test suite failed to run
TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received an instance of URL
at node_modules/.pnpm/svelte-jester@2.1.1_jest@27.1.1+svelte@3.42.4/node_modules/svelte-jester/dist/transformer.cjs:80:118
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 4
- Comments: 16 (1 by maintainers)
I’m not sure if this is related (or just my mistake) but I was trying to run the latest master branch locally and got this:
From looking at
ts-jest.log, I noticed that thegot transformed into
/path/to//node_modules/svelte-jester/dist/transformer.cjs. So I thought that maybe it’s jest that transformed the raw string into arequire, which in turn loaded the cjs file. I replaced it withAnd it seemed to work. As js/ts is not my thing, I’ll just add all the seemingly random things that my jest config has now
I tried some variations of
exportsinpackage.json, but the only way to convince Jest to use the ESM transformer was to have the ESM version as the default export. I don’t know, if this will work for the CJS transformer then.See
Seems to be related to Windows again. I will have a look at it tonight.