0

I am using ng test to run my unit tests.

I have a scenario where I need to test mutliple spec files which are in different paths.

I am able to do this using angular.json

"test": {
...
"include": ["**/test1.spec.ts","**/test2.spec.ts"],
..
}

I am able to run a single spec file using ng test --include=**/test1.spec.ts

But how to pass an array or multiple spec file path through ng test --include?

FYI: As per angular docs, ng test --include parameter is of type array.

    --include "**/test1.spec.ts,**/test2.spec.ts"
    --include="**/test1.spec.ts","**/test2.spec.ts"
    --include=["**/test1.spec.ts","**/test2.spec.ts"]
    --include=[**/test1.spec.ts,**/test2.spec.ts]

I tried all these possibilities but nothing seemed to help. Can someone help me understand how to pass multiple file path / array to --include through CLI.

1 Answer 1

0

I had the same issue.

The Angular docs say the --include parameter is of type array, but the correct syntax isn't clear.

You can specify the --include parameter multiple times, once for each file pattern:

ng test --include **/test1.spec.ts --include **/test2.spec.ts
Sign up to request clarification or add additional context in comments.

1 Comment

This worked with slight change -> ng test -- --include "**/test1.spec.ts" --include "**/test2.spec.ts"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.