Jest、ts Jest、带有ES模块导入的typescript:找不到模块

Jest、ts Jest、带有ES模块导入的typescript:找不到模块,typescript,jestjs,ts-jest,Typescript,Jestjs,Ts Jest,我很难让jest使用带有import语法的ES模块的typescript项目。 我的项目最初是为commonjs编写的,jest测试运行良好。但后来我决定切换到ES模块(用于学习目的),jest不高兴ヽ(`Д´)ノ 我正在使用的工具:typescript、jest、ts jest 问题从import语法开始 以下是我尝试过的代码 // projectRoot/src/app.ts export default someFunction = (): void => { // som

我很难让jest使用带有
import
语法的ES模块的typescript项目。 我的项目最初是为commonjs编写的,jest测试运行良好。但后来我决定切换到ES模块(用于学习目的),jest不高兴ヽ(`Д´)ノ 我正在使用的工具:typescript、jest、ts jest

问题从
import
语法开始

以下是我尝试过的代码

//  projectRoot/src/app.ts

export default someFunction = (): void => {
   // some code
}
如果

但是

如上面的例子所示,如果我导入带有扩展的模块(这是ES模块必须的),jest(或者可能是ts jest?)会不高兴。 我在网上做了一些搜索,但jest似乎不太支持ES模块。这同样适用于ts玩笑

我的项目结构:

/projectRoot
 ├── /src/app.ts
 ├── /__tests__/app.test.ts
内部package.json文件的值为“type”:“module”

tsconfig.json:

{
  "compilerOptions": {
     "target": "ES2015",
     "module": "ESNEXT",
     "outDir": "./build",
     "strict": true,
     "moduleResolution": "node",
     "esModuleInterop": true,
     "skipLibCheck": true,
     "forceConsistentCasingInFileNames": true
  },
  "include": ["./src"],
  "exclude": ["node_modules", "**/*.test.ts"]
}
jest.config.js

export default {
    "roots": [
      //"<rootDir>/src"
      "<rootDir>"
    ],
    "testMatch": [
      "**/__tests__/**/*.+(ts|tsx|js)",
      "**/?(*.)+(spec|test).+(ts|tsx|js)"
    ],
    "transform": {
      "^.+\\.(ts|tsx)$": "ts-jest"
    },
    "preset": "ts-jest",
    "testEnvironment": 'node'
  }
导出默认值{
“根”:[
//“/src”
""
],
“测试匹配”:[
“***/\uuuuuuuuuuu测试”+(ts | tsx | js)”,
“***/?(*)+(规范测试)。+(ts | tsx | js)”
],
“转变”:{
“^.+\.(ts | tsx)$”:“ts笑话”
},
“预设”:“ts玩笑”,
“测试环境”:“节点”
}

请帮忙。谢谢。

你有github回购或其他东西的链接吗?嗨@geodoo,这是我的回购
/projectRoot
 ├── /src/app.ts
 ├── /__tests__/app.test.ts
{
  "compilerOptions": {
     "target": "ES2015",
     "module": "ESNEXT",
     "outDir": "./build",
     "strict": true,
     "moduleResolution": "node",
     "esModuleInterop": true,
     "skipLibCheck": true,
     "forceConsistentCasingInFileNames": true
  },
  "include": ["./src"],
  "exclude": ["node_modules", "**/*.test.ts"]
}
export default {
    "roots": [
      //"<rootDir>/src"
      "<rootDir>"
    ],
    "testMatch": [
      "**/__tests__/**/*.+(ts|tsx|js)",
      "**/?(*.)+(spec|test).+(ts|tsx|js)"
    ],
    "transform": {
      "^.+\\.(ts|tsx)$": "ts-jest"
    },
    "preset": "ts-jest",
    "testEnvironment": 'node'
  }