0
votes

I have an Angular flavoured Nativescript project.

After follwoing the steps from https://docs.nativescript.org/tooling/testing/testing I encountered the following error:

ERROR in ./src/tests/example.ts Module build failed (from ../node_modules/@ngtools/webpack/src/index.js): Error: /home/..../src/tests/example.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.

The steps I did:

  1. tns test init - enter on jasmine
  2. npm i @types/jasmine --save-dev
  3. started my android emulator
  4. tns run android

You can see that the generated example test file does not work, but I did not read anything on the site about modifying the tsconfig.json.

1

1 Answers

2
votes

One possible solution is to ... do exactly as the error message says.

after inserting this:

"include": ["src/tests/**/*.ts"]

to the tsconfig.json (or tsconfig.tns.json), the tests run without a problem.

Although I think this means, this file gets included in every build (not just test runs) so not the best solution yet. Including this line only in the tsconfig.spec.json did not help either, it seems I have to prepare a different build for production which will not include this.