Angular.js开玩笑:测试套件无法运行语法错误:意外的标识符

时间:2019-07-26 14:54:35

标签: javascript angularjs unit-testing jestjs

对于某些现有的单元测试,我想在我的有角项目中用Jest代替Karma。我设法将所有配置都配置为仅在运行一个特定测试时出现此错误:

({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import createFind from './_createFind.js';

Syntax error: Unexpected identifier
      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:471:17)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:513:25)
      at Object.<anonymous> (node_modules/angular2-jsonapi/src/models/json-api.model.ts:1:1)`

这是我的package.json的样子:

"jest": {
    "preset": "jest-preset-angular",
    "setupFilesAfterEnv": [
      "./setupJest.ts"
    ],
    "testPathIgnorePatterns": [
      "./node_modules",
      "./dist/",
      "./src/test.ts"
    ],
    "transformIgnorePatterns": [
      "./node_modules/(?!lodash-es/)"
    ],
    "modulePaths": ["src/app"],
    "globals": {
      "ts-jest": {
        "tsConfig": "src/tsconfig.spec.json",
        "stringifyContentPathRegex": "\\.html$",
        "astTransformers": [
          "./node_modules/jest-preset-angular/InlineHtmlStripStylesTransformer"
        ],
        "diagnostics": false
      }
    }
  },

另外,我还没有删除所有与业力和茉莉有关的东西...

0 个答案:

没有答案