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

loading svelte packages from node_modules #23

Closed
darkship opened this issue Oct 15, 2020 · 4 comments
Closed

loading svelte packages from node_modules #23

darkship opened this issue Oct 15, 2020 · 4 comments

Comments

@darkship
Copy link

Not every Svelte packages are providing CommonJSmodules needed by Jest.

Examples:
svelte-select: provides es, mjs modules and the svelte component
svelte-calendar: provides only the svelte component.

Is there something I can do to tell jest that it has to look for the svelte component when it comes from node_modules?

import Select from 'svelte-select';
import * as CommonJSSelect from 'svelte-select';
const SelectComponent = Select || CommonJSSelect; // issues with jest, needs CommonJS
@mihar-22
Copy link
Collaborator

Hey @darkship you can use jest-svelte-resolver to make Jest resolve the .svelte files.

@darkship
Copy link
Author

darkship commented Oct 16, 2020

I tried it. It breaks the handling of components with svelte-jester. And I don't find the related github page of this package

@basarbk
Copy link

basarbk commented Jan 21, 2021

Hi @darkship ,
You can use "transformIgnorePatterns" configuration of jest. By default the node_modules folder is ignored. So by setting it as follows

  "transformIgnorePatterns": [
    "node_modules/(?!(svelte-select|svelte-calendar)/)"
  ],

the folders "svelte-select" and "svelte-calendar" in the node_modules, will be transformed based on the transform config.

@sebastianrothe
Copy link
Collaborator

This should be fixed with Jest 27+ and Sveltekit requiring ESM.

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

4 participants