monounity / karma-typescript

Simplifying running unit tests with coverage for Typescript projects.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Need help with typescript project references

rozamirandar opened this issue · comments

Hello,

I'm trying to add tests to a module that has a Typescript project reference but I can't get the configuration right.

Here is my branch: https://github.com/rozamirandar/karma-typescript/tree/typescript-project-references

I created a new folder called typescript-project-reference under examples.

This folder has two typescript projects:

  • shared
  • angular2 (copied from examples)

In the angular2 project, I configured karma-typescript to use the tsconfig.spec.json file that references the shared project:

"references": [ { "path": "../shared" } ]

When I run the tests I get the error:

▶ npm run test

> karma-typescript-examples-angular2@5.4.0 test /home/rodolfo/dev/angular/karma-typescript/examples/typescript-project-reference/angular2
> karma start

25 02 2021 11:29:14.344:INFO [compiler.karma-typescript]: Compiling project using Typescript 4.2.2
25 02 2021 11:29:17.754:ERROR [compiler.karma-typescript]: src/app/hello.spec.ts(5,30): error TS6305: Output file '/home/rodolfo/dev/angular/karma-typescript/examples/typescript-project-reference/shared/lib/src/app/main.d.ts' has not been built from source file '/home/rodolfo/dev/angular/karma-typescript/examples/typescript-project-reference/shared/src/app/main.ts'.

25 02 2021 11:29:17.755:ERROR [compiler.karma-typescript]: src/app/hello.ts(3,30): error TS6305: Output file '/home/rodolfo/dev/angular/karma-typescript/examples/typescript-project-reference/shared/lib/src/app/main.d.ts' has not been built from source file '/home/rodolfo/dev/angular/karma-typescript/examples/typescript-project-reference/shared/src/app/main.ts'.

25 02 2021 11:29:17.785:INFO [compiler.karma-typescript]: Compiled 3 files in 3396 ms.
25 02 2021 11:29:17.786:ERROR [karma-server]: Error during file loading or preprocessing
undefined
25 02 2021 11:29:17.786:INFO [karma-server]: Karma v6.1.0 server started at http://localhost:9876/
25 02 2021 11:29:17.787:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
25 02 2021 11:29:17.792:INFO [launcher]: Starting browser ChromeHeadless
25 02 2021 11:29:18.086:INFO [Chrome Headless 88.0.4324.150 (Linux x86_64)]: Connected on socket uUexr7N7QmfwRXQuAAAB with id 80357067

any help would be appreciated.