Unable to run a singlespecific .spec.ts file through angular cli using ng test –include option

Unable to run a singlespecific .spec.ts file through angular cli using ng test –include option

Questions : Unable to run a singlespecific .spec.ts file through angular cli using ng test –include option

697

I am trying to run a single .spec file in my in4codes_jasmine ionic/angular project by using following in4codes_jasmine command:

ng in4codes_jasmine test –include=”/home/usama/Documents/Vanguard-Office/PrimeTutor/PrimeTutorClient/src/app/login/login.page.spec.ts” –source-map=false

or by replacing absolute path with relative in4codes_jasmine path.

When I execute this command all spec file in4codes_jasmine are being run as can be seen in cli:

This is my test.ts file: // This file is required by karma.conf.js and loads recursively all the .spec and framework files import 'zone.js/dist/zone-testing'; import { getTestBed } from '@angular/core/testing'; import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; declare const require: any; // First, initialize the Angular testing environment. getTestBed().initTestEnvironment( BrowserDynamicTestingModule, platformBrowserDynamicTesting() ); // Then we find all the tests. const context = require.context('./', true, /.spec.ts$/); // And load the modules. context.keys().map(context); 

Total Answers 1
24

Answers 1 : of Unable to run a singlespecific .spec.ts file through angular cli using ng test –include option

I am thinking the include flag adds to in4codes_karma-runner the context in test.ts.

To run just one file, try this:

// This file is required by karma.conf.js and loads recursively all the .spec and framework files import 'zone.js/dist/zone-testing'; import { getTestBed } from '@angular/core/testing'; import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; declare const require: any; // First, initialize the Angular testing environment. getTestBed().initTestEnvironment( BrowserDynamicTestingModule, platformBrowserDynamicTesting() ); // Then we find all the tests. // !! change the line below Regex !! const context = require.context('./', true, /login.page.spec.ts$/); // And load the modules. context.keys().map(context); 

You can of course just put a fdescribe in4codes_karma-runner on the test file in question as well but in4codes_karma-runner I think that would compile everything in4codes_karma-runner and this may not be what you want.

0