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
Hello, I have a problem. The problem should come from my configuration. But I need help.
I used ts-jest、babel-jest and @vue/vue3-jest ,But when I run the jest, I got an error
import type { InitialOptionsTsJest } from 'ts-jest'; import { jsWithTsESM as tsjPreset } from 'ts-jest/presets'; const esModules = ['core-js'].join('|'); const config: InitialOptionsTsJest = { rootDir: process.cwd(), testEnvironment: 'jsdom', // roots: ['<rootDir>/test/'], // testRegex: '(/tests/.*|\\.(test))\\.(ts|tsx|js)$', preset: 'ts-jest/presets/js-with-ts-esm', extensionsToTreatAsEsm: ['.ts'], moduleNameMapper: { '^@/(.*)$': '<rootDir>/src/$1', '^(\\.{1,2}/.*)\\.js$': '$1' }, transform: { ...tsjPreset.transform, [`(${esModules}).+\\.js$`]: 'ts-jest', '.vue$': '@vue/vue3-jest' }, globals: { 'ts-jest': { useESM: true, // babelConfig: './babel.config.js', tsconfig: { jsx: 'preserve', jsxFragmentFactory: 'h', esModuleInterop: true, target: 'esnext', module: 'esnext', sourceMap: true, allowJs: true } }, // 'babel-jest': { // presets: ['@babel/preset-env'], // plugins: ['@babel/plugin-transform-runtime'] // }, '@vue/vue3-jest': { compilerOptions: { propsDestructureTransform: true, refTransform: false } } }, // testPathIgnorePatterns: ['node_modules'], transformIgnorePatterns: [`node_modules/(?!${esModules})`], moduleFileExtensions: ['vue', 'ts', 'js'], // collectCoverageFrom: ['**/*.{tsx,vue,ts}', '!**/node_modules/**'], // coverageReporters: ['html-spa'], // coverageDirectory: './report/jest' }; export default config;
The text was updated successfully, but these errors were encountered:
Please try this workaround:
npm install --save-dev @babel/preset-env
and add babel.config.js to your root of your project:
babel.config.js
// babel.config.js module.exports = { presets: ['@babel/preset-env'], }
Reference: #367 (comment)
Sorry, something went wrong.
Hi, will the team consider upgrading to ESM eventually?
No branches or pull requests
yanzhangshuai commentedMar 28, 2022
Hello, I have a problem. The problem should come from my configuration. But I need help.
I used ts-jest、babel-jest and @vue/vue3-jest ,But when I run the jest, I got an error
configuration
Version
The text was updated successfully, but these errors were encountered: