Привет! Я пытаюсь запустить команду ng test в своем проекте, но ng test не захватывает браузер.
Я прошел через множество ответов stackoverflow, но не повезло.
У всех есть столкнулся с той же проблемой?
Я пробовал переполнение стека.
Angular Карма не захватывает браузер
Моя карма.config. js файл такой.
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
captureTimeout: 60000,
browserDisconnectTimeout : 100000,
browserDisconnectTolerance : 1,
browserNoActivityTimeout : 60000,
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma'),
require('karma-phantomjs-launcher'),
require('karma-junit-reporter')
],
client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true,
thresholds: {
emitWarning: true,
global: {
statements: 55,
lines: 55,
branches: 55,
functions: 55
}
}
},
angularCli: {
environment: 'local'
},
reporters: ['progress', 'junit', 'kjhtml'],
// the default configuration
junitReporter: {
outputDir: 'coverage', // results will be saved as $outputDir/$browserName.xml
outputFile: 'test-result.xml', // if included, results will be saved as $outputDir/$browserName/$outputFile
useBrowserName: false, // add browser name to report and classes names
nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: true
});
};
упаковка. json
{
"name": "c",
"version": "1.0.0-B162",
"license": "C",
"scripts": {
"ng": "ng",
"start": "ng serve --aot --sourcemaps=true",
"build": "ng build --aot --sourcemaps=true --output-hashing=all",
"local-build": "ng build --env=local",
"dev2-build": "ng build --env=dev2",
"prod-build": "ng build --target production --build-optimizer --vendor-chunk",
"test": "ng test",
"code-coverage": "ng test -cc --browser Chrome",
"lint": "ng lint --force --format checkstyle > ./coverage/tslint-result.xml",
"e2e": "ng e2e",
"package-web": "cp .htaccess dist | tar -czvf spp-web.tar.gz -C dist .",
"package-conf": "tar -czvf spp-conf.tar.gz -C httpd/ ."
},
"private": true,
"dependencies": {
"@angular/animations": "5.2.9",
"@angular/common": "5.2.9",
"@angular/compiler": "5.2.9",
"@angular/core": "5.2.9",
"@angular/forms": "5.2.9",
"@angular/http": "5.2.9",
"@angular/platform-browser": "5.2.9",
"@angular/platform-browser-dynamic": "5.2.9",
"@angular/router": "5.2.9",
"angular-in-memory-web-api": "^0.5.4",
"bootstrap": "^3.3.7",
"chart.js": "^2.8.0",
"classlist.js": "^1.1.20150312",
"core-js": "^2.5.3",
"export-to-csv": "^0.2.1",
"font-awesome": "^4.7.0",
"intl": "^1.2.5",
"jquery": "^3.2.1",
"jsencrypt": "^2.3.1",
"lodash": "^4.17.4",
"moment": "^2.19.2",
"primeng": "~5.0.0",
"rxjs": "^5.5.7",
"web-animations-js": "^2.3.1",
"zone.js": "^0.8.20"
},
"devDependencies": {
"@angular/cli": "^1.7.3",
"@angular/compiler-cli": "5.2.9",
"@angular/language-service": "5.2.9",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/lodash": "4.14.108",
"@types/moment": "^2.13.0",
"@types/node": "~6.0.60",
"angular-tslint-rules": "^1.0.4",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-junit-reporter": "^1.2.0",
"karma-phantomjs-launcher": "^1.0.4",
"phantomjs": "^2.1.7",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "2.4.2"
}
}