3

I upgraded my app from angular4 to angular 5 following the steps mentioned here: https://update.angular.io/

I am able to run ng-serve , ng build etc without any issue.

But ng test (npm test) is failing with error:

\src\test.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.

I tried doing enough google and solving this issue but none of them seems to be working.

As suggested here, https://stackoverflow.com/a/48798373/2754029 I tried to add the config in angular-cli.json and tsconfig.json but that doesn't work.

Can anyone please help me here. Let me know if you need any more info in this regard.

georgeawg
  • 48,608
  • 13
  • 72
  • 95
undefined
  • 3,464
  • 11
  • 48
  • 90

1 Answers1

0

In my case, that's because ng test uses tsconfig.spec.json, instead of tsconfig.json. Check your tsconfig.spec.json and that your test.ts is listed in files section.

You can see / change which tsconfig to be used at following section of angular.json.

{
  "projects": {
    "YOUR_PROJECT": {
      "architect": {
        "test": {
          "options": {
            "tsConfig": "tsconfig.spec.json", // <---- See here
            "karmaConfig": "src/YOUR_PROJECT/karma.conf.js"

See https://angular.io/guide/file-structure#default-app-project-files for more information. Hope it helps.

otiai10
  • 4,289
  • 5
  • 38
  • 50