I am trying to run a single spec.ts file, but Angular keeps picking up many other files. Here is what I have tried:
ng test --include src\app\global.service.spec.ts
ng test --main src\app\global.service.spec.ts
ng test --include [FULL PATH]\src\app\global.service.spec.ts
ng test (no params, but with the karma file configured with the following):
module.exports = function (config) {
config.set({
files: [{ pattern: 'src\\app\\global.service.spec.ts', watched: false }],
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
},
coverageIstanbulReporter: {
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
coverageReporter: {
dir: require('path').join(__dirname, 'coverage'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' },
{ type: 'lcov' }
]
},
reporters: ['progress', 'kjhtml', 'coverage' ],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true,
customLaunchers: {
MyHeadlessChrome: {
base: 'ChromeHeadless',
flags: [
'--headless',
'--disable-gpu',
'--disable-web-security',
'--disable-translate',
'--disable-extensions',
'--no-sandbox',
'--remote-debugging-port=9222',
],
},
},
});
};