-
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
Compatibility with Yarn 2 (PnP) #36
Comments
For SvelteKit, we highly recommend you not use Yarn: https://kit.svelte.dev/faq#integrations |
Noted @benmccann ! I think for this library there is no inherent restriction in Yarn Berry that would prevent it to be patched for those interested in using Yarn 2 with Svelte? Everything else works fine, it is just this dependency I couldn't get to work! |
This should be fixed with Jest 27+ and using the async transformer aka ESM-mode. Can you please retry with the latest version? |
Thank you for looking into this!! I tried testing this out but somehow always got stuck with the following error:
This is using a new project created with:
And then following the instructions from the svelte jester readme. Here the dependencies:
jest.config.js
svelte.config.js
and here reference to the remainder of the source https://github.com/goldstack/goldstack/tree/svelte/workspaces/templates/packages/app-svelte-2 I tried experimenting with enabling experimental ESM as well but that resulted in other errors. Would that be required to use this? |
Everyone was getting that error. It should be fixed in |
Sorry about the delay, |
Thank you, I think this issue is resolved in Using this config now jest.config.js // eslint-disable-next-line @typescript-eslint/no-var-requires
const base = require('./../../jest.config.ui');
module.exports = {
...base,
globals: {
'ts-jest': {
tsconfig: 'tsconfig.json',
isolatedModules: true,
},
},
testEnvironment: 'node',
preset: 'ts-jest',
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
transform: {
'^.+\\.svelte$': [ 'svelte-jester', { preprocess: './svelte.test.config.js'}],
'^.+\\.ts$': 'ts-jest',
'^.+\\.tsx$': 'ts-jest',
'^.+\\.js$': 'ts-jest',
'^.+\\.jsx$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'js', 'svelte'],
}; But the problem is when I try to run a test defined as follows App.uispec.ts: import App from './App.svelte';
import dummy from './dummy';
// import { render, fireEvent } from '@testing-library/svelte';
describe('Svelte tests', () => {
it('Should render component', () => {
expect(true).toEqual(true);
// const { getByText } = render(App, { name: 'User' });
// // expect(getByText('Hello User')).toBeInTheDocument();
// console.log(getByText('Hello User'));
});
}); I get an error:
So it can import import dummy from './dummy'; But it fails to import: import App from './App.svelte'; Somehow svelte.test.config.js is not even loaded. Is there something wrong in the jest config? |
Yes, trying to run this on Windows. So would this need a fix in the library or is there a workaround? |
You can downgrade to 1.x or go all the way in with ESM. See Jest docs about this. |
Thank you for looking into it. I would assume going to 1.x would surface the original problem? Also I think would be best to avoid having to use ESM given it is not yet supported in Yarn 2 yarnpkg/berry#638 . |
SvelteKit switched to ESM. So if you have a config in ESM, you have to switch too. |
Thanks for this useful library. I was wondering if this works together with Yarn 2 Plug'n'play (pnp)?
I am getting the following error:
I assume this is caused by the following command in transformer.js#L16 not taking into account the Yarn PnP loader?
Jest I think in other places automatically uses the PnP loader.
The text was updated successfully, but these errors were encountered: