Ecmascript 6 e babel文档已更新,以在正则表达式中指定.ts文件。不需要任何其他类型脚本的依赖项,如ts jest。我确实需要@babel/预设打字脚本。将其添加到.babelrc文件中的预设列表中。 var Validation = require('..

Ecmascript 6 e babel文档已更新,以在正则表达式中指定.ts文件。不需要任何其他类型脚本的依赖项,如ts jest。我确实需要@babel/预设打字脚本。将其添加到.babelrc文件中的预设列表中。 var Validation = require('..,ecmascript-6,jestjs,babel-jest,Ecmascript 6,Jestjs,Babel Jest,e babel文档已更新,以在正则表达式中指定.ts文件。不需要任何其他类型脚本的依赖项,如ts jest。我确实需要@babel/预设打字脚本。将其添加到.babelrc文件中的预设列表中。 var Validation = require('../src/components/validation/validation'); // PASS //import * as Validation from '../src/components/validation/validation

e babel文档已更新,以在正则表达式中指定.ts文件。不需要任何其他类型脚本的依赖项,如ts jest。我确实需要@babel/预设打字脚本。将其添加到.babelrc文件中的预设列表中。
   var Validation = require('../src/components/validation/validation'); // PASS
   //import * as Validation from '../src/components/validation/validation' // FAIL
 "scripts": {
    "start": "webpack-dev-server",
    "test": "jest"
  },
      "jest": {
        "testPathDirs": [
          "__tests__"
        ],
        "testPathIgnorePatterns": [
          "/node_modules/"
        ],
        "testFileExtensions": ["es6", "js"],
        "moduleFileExtensions": ["js", "json", "es6"]
      },
{
  "presets": ["es2015", "react"],
  "plugins": ["transform-decorators-legacy"]
}
{
  "presets": ["es2015", "react", "stage-0"],
  "plugins": ["transform-decorators-legacy"]
}
{
  "env": {
    "test": {
      "plugins": ["@babel/plugin-transform-modules-commonjs"]
    }
  }
}
npm install --save-dev @babel/plugin-transform-modules-commonjs
npm install --save-dev babel-jest
{
  "scripts": {
    "test": "jest"
  },
  "jest": {
    "transform": {
      "^.+\\.jsx?$": "babel-jest"
    }
  }
}
npm install @babel/preset-env --save-dev
{
  "presets": ["@babel/preset-env"]
}
npm run test
export default {
    testEnvironment: 'jest-environment-node',
    transform: {}
    ...
};
node --experimental-vm-modules node_modules/jest/bin/jest.js
import {jest} from '@jest/globals'