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

Recipe for using TypeScript and Jest tests at the same time #149

Open
atuttle opened this issue Oct 14, 2021 · 5 comments
Open

Recipe for using TypeScript and Jest tests at the same time #149

atuttle opened this issue Oct 14, 2021 · 5 comments
Labels
stale Issue or PR haven't be update for a while

Comments

@atuttle
Copy link

atuttle commented Oct 14, 2021

There's a recipe for using TypeScript and a recipe for writing tests with Jest, but nothing to get them both running together. I can write components using TS but as soon as I try to test them it all falls apart. I've never used Jest and TS together before, so a recipe would be extremely helpful.

@benmccann
Copy link
Collaborator

I believe that svelte-add-jest has TypeScript support. Probably the easiest thing to do would be to use it: https://github.com/rossyman/svelte-add-jest

I think that for setting up any integration, Svelte Adders is basically always the easiest way to manage it. Not sure if there's something we should do to make that more discoverable

@atuttle
Copy link
Author

atuttle commented Oct 17, 2021

Interesting, I may have to give that a try.

I did find this and while it's slightly out of date (uses Jest 26 and with v27 requires setting "testEnvironment": "jsdom") it's pretty helpful.

@benmccann
Copy link
Collaborator

svelte-add-jest uses Jest 27 and also avoids starting a new process for each test, which is only possible with Jest 27

@atuttle
Copy link
Author

atuttle commented Oct 18, 2021

The docs seem to indicate that svelte-add-jest is for SvelteKit specifically. Will it work on vanilla Svelte?

@benmccann
Copy link
Collaborator

Probably not though perhaps. But I imagine you could see what it changed and then make the same changes in your project

@MacFJA MacFJA added the stale Issue or PR haven't be update for a while label Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Issue or PR haven't be update for a while
Projects
None yet
Development

No branches or pull requests

3 participants