-
Notifications
You must be signed in to change notification settings - Fork 85
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
SyntaxError: Unexpected token 'export' while running jest test cases #345
Comments
Can you set script to ESM somehow? |
@jakobrosenberg You can find the import statement in the first screenshot |
If I'm reading the screenshot correctly, you haven't configured Jest to handle ESM. |
Same error here, is this looked upon? |
Does this help? #349 |
We would need to ignore transform patterns for ESM. Below are the sample code for the reference.
Let me know if any question, happy to help you. |
Same issue here |
I think you need to configure Jest as Jake said to support esm. If you still having issues please reopen |
Thanks for this @vikaspuri-goswami! Unfortunately, neither the Dependency versions used: "@roxi/routify": "^2.18.5",
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/svelte": "^3.0.3",
"@tsconfig/svelte": "^3.0.0",
"jest": "^27.5.1",
"svelte": "^3.46.4",
"svelte-check": "^2.4.5",
"svelte-jester": "^2.3.2",
"svelte-preprocess": "^4.10.4",
"ts-jest": "^27.1.3",
"ts-node": "^10.7.0",
"tslib": "^2.3.1",
"typescript": "^4.6.2", jest.config.ts import type { Config } from '@jest/types';
const config: Config.InitialOptions = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
verbose: true,
transform: {
'^.+\\.svelte$': [
'svelte-jester',
{
preprocess: true
}
],
'^.+\\.ts$': 'ts-jest',
'^.+\\.js$': 'ts-jest',
'.+\\.(css|styl|less|sass|scss)$': 'jest-css-modules-transform'
},
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
moduleFileExtensions: ['js', 'ts', 'svelte'],
transformIgnorePatterns: ['<rootDir>/node_modules/(?!@roxi)']
};
export default config; I've also tried: "test": "NODE_OPTIONS=--experimental-vm-modules jest src", I'll share back if I find a fix - if someone else has any suggestions in the meantime, would greatly appreciate it 🙏 Thanks cc @ghostdevv |
@tobiasbueschel I'm facing the same problem - have you found a solution meanwhile? |
I would recommend migrating to Vitest, for the most part it should be a drop in replacement for Jest as it supports the Jest mock syntax OOTB |
Any solution for this issue? |
SyntaxError: Unexpected token 'export' while running jest test cases.
bable.config.js
Jest configuration in package.json
Screenshot attached
The text was updated successfully, but these errors were encountered: