Search code examples
angulartypescriptjestjstsconfigangular-test

NWL NX Angular Jest tests are reporting "unable to find describe" errors


Does anyone know why my Angular Jest Tests are reporting: error TS2593: Cannot find name 'describe’. ??

I have an NWL NX Workspace running an Angular App & Multiple Libs.

The tests in all the Libs are running fine. The tests in the App are all reporting this error. I have not edited the config - so these should be the config from the NX setup. How do I fix this?? Any ideas?

App TsConfigs: // tsconfig.json

{
  "extends": "../../tsconfig.base.json",
  "compilerOptions": {
    "typeRoots": ["node_modules/@types"],
    "types" : ["node"],
  },
  "files": [],
  "include": [],
  "references": [
    {
      "path": "./tsconfig.app.json"
    },
    {
      "path": "./tsconfig.spec.json"
    },
    {
      "path": "./tsconfig.editor.json"
    }
  ]
}

// tsconfig.app.json

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "../../dist/out-tsc",
    "typeRoots": ["node_modules/@types"],
    "types" : ["node"],
  },
  "files": ["src/main.ts", "src/polyfills.ts"]
}

// tsconfig.spec.json

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "../../dist/out-tsc",
    "module": "commonjs",
    "types": ["jest", "node"]
  },
  "files": ["src/test-setup.ts"],
  "include": ["**/*.spec.ts", "**/*.d.ts"]
}

Solution

  • So this did not work for me:

    "compilerOptions": {
        "typeRoots": ["node_modules/@types"],
        "types" : ["node", "jest"],
      },
    

    But this did: ???

    "compilerOptions": {
      },
    

    No Idea why though.