20

I have seen this and this posts and they have made me understand tsconfig.app.json and tsconfig.json.

I have an angular app which has tsconfig.app.json, tsconfig.json and tsconfig.spec.json

What is the role of tsconfig.spec.json? What does the 'spec' in tsconfig.spec.json stand for?

YulePale
  • 6,688
  • 16
  • 46
  • 95
  • 1
    It is for testing. – mr. pc_coder Jun 27 '20 at 09:38
  • I believe 'spec' is short for specification(s). The idea - as I understand it - is that a package's tests should be checking that the specifications (a codified version of the needs/requirements/expecations/deliberables) are met. – Leif Jones Feb 19 '21 at 16:39
  • See also https://stackoverflow.com/questions/52890331/how-to-use-different-tsconfig-file-for-tests and https://stackoverflow.com/questions/35470511/setting-up-tsconfig-with-spec-test-folder?noredirect=1&lq=1 and https://stackoverflow.com/questions/54865419/can-we-exclude-tsconfig-spec-json-from-an-angular-application – Michael Freidgeim Mar 05 '23 at 18:43

1 Answers1

18

It is TypeScript configuration for the application tests.

For example below code you says

"types": ["jasmine", "node"]

I will use jasmine for testing on nodejs environment.

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/spec",
    "module": "commonjs",
    "target": "es5",
    "baseUrl": "",
    "types": [
      "jasmine",
      "node"
    ]
  },
  "files": [
    "test.ts",
    "polyfills.ts"
  ],
  "include": [
    "**/*.spec.ts",
    "**/*.d.ts"
  ]
}
mr. pc_coder
  • 16,412
  • 3
  • 32
  • 54
  • 1
    According to https://www.typescriptlang.org/tsconfig#types types declaration only describes which ./node_modules/@types/ subfolders are included. The main condition of tsconfig.spec.json file is to specify test files in "include": [ "**/*.spec.ts" . Is the name tsconfig.spec.json just convention? Can someone use different config file name, e.g. tsconfig.test.json for the same purpose? – Michael Freidgeim Mar 05 '23 at 17:35