我一直在我的Angular 4应用程序的Chrome浏览器上运行我的Protractor测试。我想使用Headless Chrome,但是当我切换到Headless Chrome配置时,它会阻止我在通过ng测试运行测试时关注特定测试。例如,如果我为测试用例执行“fDescribe”,它仍会运行我的所有Protractor测试。有没有人有任何想法,Headless chrome中的配置更改会阻止焦点从fDescribe和fIt开始工作?
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
var jasmineReporters = require('jasmine-reporters');
var phantomJSPath = require('phantomjs-prebuilt').path;
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
// 'browserName': 'phantomjs',
'browserName': 'chrome',
'loggingPrefs': { browser: "ALL" },
'phantomjs.binary.path': phantomJSPath,
'chromeOptions': {
'args': ['--headless', '--disable-gpu', 'window-size=1400x800', 'disable-infobars']
},
shardTestFiles: true,
//maxInstances: 3
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 60000,
print: function () { }
},
onPrepare() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
savePath: './',
filePrefix: 'xmlresults'
}));
var fs = require('fs-extra');
fs.emptyDir('screenshots/', function (err) {
console.log(err);
});
jasmine.getEnv().addReporter({
specDone: function(result) {
if (result.status == 'failed') {
browser.getCapabilities().then(function (caps) {
var browserName = caps.get('browserName');
browser.takeScreenshot().then(function (png) {
var stream = fs.createWriteStream('screenshots/' + browserName + '-' + result.fullName.substring(0, 20) + '.png');
stream.write(new Buffer(png, 'base64'));
stream.end();
});
});
}
}
});
},
//HTMLReport called once tests are finished
onComplete: function () {
var browserName, browserVersion;
var capsPromise = browser.getCapabilities();
capsPromise.then(function (caps) {
browserName = caps.get('browserName');
browserVersion = caps.get('version');
var HTMLReport = require('protractor-html-reporter');
testConfig = {
reportTitle: 'Query Tool e2e Test Execution Report',
outputPath: './',
screenshotPath: './screenshots',
testBrowser: browserName,
browserVersion: browserVersion,
modifiedSuiteName: false,
screenshotsOnlyOnFailure: true
};
new HTMLReport().from('./xmlresults.xml', testConfig);
});
}
};
答案 0 :(得分:1)
--headless
没有突破重点,问题出在shardTestFiles: true
,与茉莉fdescribe()
fit()
不兼容。
点击此处: