Jest
- Native support for ES modulesGitHub Issuefacebook/jest#4842
- Issue Comment: ES ModulesGitHub Issuefacebook/jest#9395
'^.+\\.jsx?$': ['babel-jest', {configFile: './babel.config.jest.js'}],- Jest Configuration链接jestjs.io/docs/en/configurationNative support for ES modules · Issue Comment: ES Modules · Jest Configuration · 默认规则: · Visual Testing · americanexpress/jest-image-snapshot笔记:Jest
默认规则:
[ "**/**tests**/**/_.[jt]s?(x)", "\*\*/?(_.)+(spec|test).[jt]s?(x)" ]
- Visual Testing
- americanexpress/jest-image-snapshotGitHubamericanexpress/jest-image-snapshotNative support for ES modules · Issue Comment: ES Modules · Jest Configuration · 默认规则: · Visual Testing · americanexpress/jest-image-snapshot笔记:Jest
npm i --save-dev jest babel-jest @babel/preset-envtransform: {
"^.+\\.jsx?$": "babel-jest"
},{
"presets": ["@babel/preset-env"]
}yarn add --dev jest ts-jest @types/jest/**
* @jest-environment node
*/jest.config.js
const { pathsToModuleNameMapper } = require('ts-jest/utils');
const { compilerOptions } = require('./tsconfig');
module.exports = {
setupFiles: ['<rootDir>/jest.setup.js'],
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
},
globals: {
'ts-jest': {
// tsConfig: 'tsconfig.jest.json',
tsConfig: 'tsconfig.json',
},
},
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/' }),
};jest.setup.js
require('dotenv').config();Cannot use import statement outside a module
关联信息
反向链接、本文链接的其他页面和外部资料。
参考资料
GitHub3 条
- americanexpress/jest-image-snapshotgithub.com/americanexpress/jest-image-snapshot
- facebook/jest#4842github.com/facebook/jest/issues/4842
- facebook/jest#9395github.com/facebook/jest/issues/9395
其他外链1 条
- jestjs.io/docs/en/configurationjestjs.io/docs/en/configuration