Skip to content
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

SvelteKit/TypeScript support? #67

Open
JPtenBerge opened this issue Apr 6, 2022 · 0 comments
Open

SvelteKit/TypeScript support? #67

JPtenBerge opened this issue Apr 6, 2022 · 0 comments

Comments

@JPtenBerge
Copy link

JPtenBerge commented Apr 6, 2022

Hi there,

I was wondering if a testing scenario with SvelteKit with TypeScript is supported. I've tried it, I have such a project and I've followed your readme by installing svelte-mock and updated my jest.config.cjs, but this error appears when I then run Jest:

Test suite failed to run

Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax. 

...

Details:

C:\myproj\src\__tests__\MyTest.test.ts:4
import '@testing-library/jest-dom';
^^^^^^

SyntaxError: Cannot use import statement outside a module

  at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1728:14)

SvelteKit came with this Jest configuration out-of-the-box:

transform: {
	"^.+\\.svelte$": [
		"svelte-jester",
		{ preprocess: "./svelte.config.test.cjs" },
	],
	"^.+\\.ts$": "ts-jest",
	"^.+\\.js$": "ts-jest",
},

I've tried mixing, matching and merging these configurations for a bit, but I'm making no progress whatsoever. So I thought I'd just ask, is a SvelteKit and TypeScript scenario supported?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant