0
votes

In my project we have unit tests files which ends with .spec.ts and protractor test cases which ends with .prot.spec.ts. Now when I run command 'ng test' my protractor files get picked up because it also has the same extention (.spec.ts) but I dont want them to execute. I tried adding the properties like 'exclude' in tsconfig.json, tsconfig.app.json, test.js but it seems that its not working.

I need to know what is the exact place where I can put my configuration so that my protractor files will be excluded.

Please find the screenshots below :

tsConfig.spec.ts

test.js

tsconfig.ts

Error

1
@Indragith : we cannot add the 'exclude' property in angular.json, It gives following error. Schema validation failed with the following errors: Data path "" should NOT have additional properties(exclude). - pritampanhale
You could change the names of your protractor tests to prot.test.ts and then have the protractor configuration file point to *.test.ts. Then ng-test should only pick up karma tests and ng-e2e should pick up protractor tests. - Sankalan Parajuli
@SankalanParajuli : Yup, Thats the last option. Thank you! - pritampanhale
@pritampanhale: If I am not wrong, with the latest angular cli version you should add the codeCoverageExclude: ['specify the path here'] instead of codeCoverage: { exclude : [] } - Indragith

1 Answers

0
votes

in your test.js, change the glob in the context

const context = require.context('./', true, /^((?!prot).)*\.spec.ts$/);