From 3c10825d185cdf4f9243b8f2621cda53d1dabc3a Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 15 Jan 2016 23:22:11 +0200 Subject: [PATCH] clarify e2e tests output --- package.json | 1 + protractor.conf.js | 7 ++++++- tests/e2e/.eslintrc | 3 +++ tests/e2e/helpers.js | 19 ++++++++++++++----- tests/e2e/redoc.spec.js | 6 +++--- 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 3343277b..8ab64634 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/protractor.conf.js b/protractor.conf.js index 56d1ff06..6c22de3a 100644 --- a/protractor.conf.js +++ b/protractor.conf.js @@ -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() {} } }; diff --git a/tests/e2e/.eslintrc b/tests/e2e/.eslintrc index 23559e82..59cc258f 100644 --- a/tests/e2e/.eslintrc +++ b/tests/e2e/.eslintrc @@ -5,5 +5,8 @@ "node": true, "jasmine": true, "protractor": true + }, + "rules": { + "no-console": 0, } } diff --git a/tests/e2e/helpers.js b/tests/e2e/helpers.js index 5272d4e7..344e0712 100644 --- a/tests/e2e/helpers.js +++ b/tests/e2e/helpers.js @@ -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`); }); } diff --git a/tests/e2e/redoc.spec.js b/tests/e2e/redoc.spec.js index 456dfbc7..24861182 100644 --- a/tests/e2e/redoc.spec.js +++ b/tests/e2e/redoc.spec.js @@ -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}`); } });