我正在尝试使用Jest运行Typescript代码的Typescript测试。我尝试使用多种形状的ts-jest来配置Jest,但是没有成功。
我得到了:
node_modules/@polkadot/api/promise/index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
^^^^^^
SyntaxError: Cannot use import statement outside a module
1 | import log4js from "log4js";
> 2 | import { ApiPromise } from "@polkadot/api/promise";
| ^
我的jest.config.ts:
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
import type { Config } from "@jest/types";
// Sync object
const config: Config.InitialOptions = {
roots: ["./"],
preset: "ts-jest",
coverageDirectory: "../coverage",
verbose: true,
testEnvironment: "node",
//setupFilesAfterEnv: ["./jest.setup.ts"],
testMatch: ["**/?(*.)+(test).ts"],
resetMocks: true,