clarify e2e tests output

This commit is contained in:
Roman Hotsiy 2016-01-15 23:22:11 +02:00
parent b9c296f700
commit 3c10825d18
5 changed files with 27 additions and 9 deletions

View File

@ -63,6 +63,7 @@
"isparta": "^4.0.0",
"istanbul": "github:gotwarlost/istanbul#source-map",
"jasmine-core": "^2.4.1",
"jasmine-spec-reporter": "^2.4.0",
"jspm": "^0.16.19",
"karma": "^0.13.15",
"karma-babel-preprocessor": "^5.2.2",

View File

@ -9,6 +9,10 @@ exports.config = {
baseUrl: 'http://localhost:3000',
framework: 'jasmine2',
onPrepare: function() {
var SpecReporter = require('jasmine-spec-reporter');
// add jasmine spec reporter
jasmine.getEnv().addReporter(new SpecReporter({displaySpecDuration: true}));
// load APIs.guru list
return loadJson('https://apis-guru.github.io/api-models/api/v1/list.json').then((list) => {
global.apisGuruList = list;
@ -18,6 +22,7 @@ exports.config = {
useAllAngular2AppRoots: true,
jasmineNodeOpts: {
showTiming: true,
showColors: true
showColors: true,
print: function() {}
}
};

View File

@ -5,5 +5,8 @@
"node": true,
"jasmine": true,
"protractor": true
},
"rules": {
"no-console": 0,
}
}

View File

@ -22,20 +22,29 @@ function loadJson(url) {
return promise;
}
const LogLevel = {
INFO: 800,
WARNING: 900
};
const MAX_ERROR_MESSAGE_SYMBOLS = 128;
//copied from angular/modules/angular2/src/testing/e2e_util.ts
function verifyNoBrowserErrors() {
// Bug in ChromeDriver: Need to execute at least one command
// so that the browser logs can be read out!
browser.executeScript('1+1');
browser.manage().logs().get('browser').then(function(browserLog) {
var filteredLog = browserLog.filter(function(logEntry) {
if (logEntry.level.value >= browser.webdriver.logging.Level.INFO.value) {
//console.log('>> ' + logEntry.message);
let filteredLog = browserLog.filter((logEntry) => {
if (logEntry.level.value >= LogLevel.INFO) {
let message = logEntry.message;
if (message.length > MAX_ERROR_MESSAGE_SYMBOLS) {
message = message.substr(0, MAX_ERROR_MESSAGE_SYMBOLS) + '...';
}
console.log('>> ' + message);
}
return logEntry.level.value > browser.webdriver.logging.Level.WARNING.value;
return logEntry.level.value > LogLevel.WARNING;
});
expect(filteredLog.length).toEqual(0);
expect(filteredLog.length).toEqual(0, `Found ${filteredLog.length} browser errors`);
});
}

View File

@ -15,7 +15,7 @@ function basicTests(swaggerUrl, title) {
verifyNoBrowserErrors();
});
it('should exist redoc element', () => {
it('should init redoc without errors', () => {
browser.get(specUrl);
let $redoc = $('redoc');
expect($redoc.isPresent()).toBe(true);
@ -25,7 +25,7 @@ function basicTests(swaggerUrl, title) {
});
}
basicTests();
basicTests(null, 'Extended Petstore');
describe('Scroll sync', () => {
@ -48,6 +48,6 @@ describe('APIs.guru specs test', ()=> {
// temporary hack due to this issue: https://github.com/substack/https-browserify/issues/6
url = url.replace('https://', 'http://');
url = url.replace('apis-guru.github.io/', 'apis-guru.github.io:80/');
basicTests(url, `${apiName} ${apiInfo.version}`);
basicTests(url, `${apiName}:${apiInfo.info.version}\n${url}`);
}
});