-
Notifications
You must be signed in to change notification settings - Fork 361
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: Cannot use import statement outside a module #914
Comments
I am having exactly the same issue |
So, I solved it by adding the following to my jest.config.js (I am using jest-preset-angular):
|
Thanks, I tried your config, but it didn't change anything for me :( |
Same here, tried the config
and it changed nothing for me too. Does someone has any other solutions? |
The error disappears when I downgrade the dependency to 14.1.3 package.json:
|
Yep, that is the only solution for now |
Thank you, this solved the issue for me for now. |
Jest doesnt work anymore with ngx-toaster after updating to Version 14.x.x, caused by using "mjs".
There is currently no angular jest preset, that works with ngx-toaster *.mjs
Jest Error:
● Test suite failed to run
Jest Config:
"use strict";
module.exports = {
testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
resolver: '@nrwl/jest/plugins/resolver',
moduleFileExtensions: ['ts', 'js','mjs', 'html'],
coverageReporters: ['html'],
transform: {
'^.+\.(ts|js|mjs|html)$': 'ts-jest',
},
testEnvironment: 'jsdom',
};
module.exports = {
name: 'user-management',
preset: '../../../jest.preset.js',
setupFilesAfterEnv: ['/src/test-setup.ts'],
globals: {
'ts-jest': {
tsconfig: '/tsconfig.spec.json',
stringifyContentPathRegex: '\.(html|svg)$',
diagnostics: { warnOnly: true },
astTransformers: [
'jest-preset-angular/build/InlineFilesTransformer',
'jest-preset-angular/build/StripStylesTransformer',
],
isolatedModules: true,
},
},
coverageDirectory: '../../../coverage/libs/biskin-kit/user-management',
transform: {
'^.+\.(ts|js|mjs|html)$': 'jest-preset-angular',
'^.+\.m?js$': 'ts-jest',
},
transformIgnorePatterns: ['/node_modules/(?!@ngx-toastr)'],
snapshotSerializers: [
'jest-preset-angular/build/serializers/no-ng-attributes',
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
moduleFileExtensions: ['ts', 'tsx', 'js', 'mjs', 'jsx', 'json', 'html'],
modulePathIgnorePatterns: ['/dist/'],
moduleNameMapper: {
'.+\.(mdx?)$': 'identity-obj-proxy',
},
clearMocks: true,
};
The text was updated successfully, but these errors were encountered: