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", "isparta": "^4.0.0",
"istanbul": "github:gotwarlost/istanbul#source-map", "istanbul": "github:gotwarlost/istanbul#source-map",
"jasmine-core": "^2.4.1", "jasmine-core": "^2.4.1",
"jasmine-spec-reporter": "^2.4.0",
"jspm": "^0.16.19", "jspm": "^0.16.19",
"karma": "^0.13.15", "karma": "^0.13.15",
"karma-babel-preprocessor": "^5.2.2", "karma-babel-preprocessor": "^5.2.2",

View File

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

View File

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

View File

@ -22,20 +22,29 @@ function loadJson(url) {
return promise; return promise;
} }
const LogLevel = {
INFO: 800,
WARNING: 900
};
const MAX_ERROR_MESSAGE_SYMBOLS = 128;
//copied from angular/modules/angular2/src/testing/e2e_util.ts //copied from angular/modules/angular2/src/testing/e2e_util.ts
function verifyNoBrowserErrors() { function verifyNoBrowserErrors() {
// Bug in ChromeDriver: Need to execute at least one command // Bug in ChromeDriver: Need to execute at least one command
// so that the browser logs can be read out! // so that the browser logs can be read out!
browser.executeScript('1+1'); browser.executeScript('1+1');
browser.manage().logs().get('browser').then(function(browserLog) { browser.manage().logs().get('browser').then(function(browserLog) {
var filteredLog = browserLog.filter(function(logEntry) { let filteredLog = browserLog.filter((logEntry) => {
if (logEntry.level.value >= browser.webdriver.logging.Level.INFO.value) { if (logEntry.level.value >= LogLevel.INFO) {
//console.log('>> ' + logEntry.message); let message = logEntry.message;
if (message.length > MAX_ERROR_MESSAGE_SYMBOLS) {
message = message.substr(0, MAX_ERROR_MESSAGE_SYMBOLS) + '...';
} }
return logEntry.level.value > browser.webdriver.logging.Level.WARNING.value; console.log('>> ' + message);
}
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(); verifyNoBrowserErrors();
}); });
it('should exist redoc element', () => { it('should init redoc without errors', () => {
browser.get(specUrl); browser.get(specUrl);
let $redoc = $('redoc'); let $redoc = $('redoc');
expect($redoc.isPresent()).toBe(true); expect($redoc.isPresent()).toBe(true);
@ -25,7 +25,7 @@ function basicTests(swaggerUrl, title) {
}); });
} }
basicTests(); basicTests(null, 'Extended Petstore');
describe('Scroll sync', () => { 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 // temporary hack due to this issue: https://github.com/substack/https-browserify/issues/6
url = url.replace('https://', 'http://'); url = url.replace('https://', 'http://');
url = url.replace('apis-guru.github.io/', 'apis-guru.github.io:80/'); 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}`);
} }
}); });