diff --git a/tests/e2e/helpers.js b/tests/e2e/helpers.js index 0b570074..8c097368 100644 --- a/tests/e2e/helpers.js +++ b/tests/e2e/helpers.js @@ -82,9 +82,21 @@ function fixFFTest(done) { }) } +/* picks each n-th property from object */ +function eachNth(obj, n) { + let res = {}; + Object.keys(obj).forEach((k, idx) => { + if (idx % n === 0) { + res[k] = obj[k]; + } + }); + return res; +} + module.exports = { loadJson: loadJson, verifyNoBrowserErrors: verifyNoBrowserErrors, scrollToEl: scrollToEl, - fixFFTest: fixFFTest + fixFFTest: fixFFTest, + eachNth: eachNth } diff --git a/tests/e2e/redoc.spec.js b/tests/e2e/redoc.spec.js index 0f88407d..e53a3a03 100644 --- a/tests/e2e/redoc.spec.js +++ b/tests/e2e/redoc.spec.js @@ -2,6 +2,7 @@ const verifyNoBrowserErrors = require('./helpers').verifyNoBrowserErrors; const scrollToEl = require('./helpers').scrollToEl; const fixFFTest = require('./helpers').fixFFTest; +const eachNth = require('./helpers').eachNth; const URL = 'index.html'; @@ -35,7 +36,7 @@ basicTests(null, 'Extended Petstore'); describe('Scroll sync', () => { let specUrl = URL; - + beforeEach((done) => { browser.get(specUrl); fixFFTest(done); @@ -59,6 +60,14 @@ describe('APIs.guru specs test', ()=> { delete apisGuruList['googleapis.com:mirror']; // bad urls in images delete apisGuruList['googleapis.com:discovery']; // non-string references + // run quick version of e2e test on all builds except releases + if (process.env.TRAVIS && !process.env.TRAVIS_TAG) { + console.log('Running on short APIs guru list'); + apisGuruList = eachNth(apisGuruList, 10); + } else { + console.log('Running on full APIs guru list') + } + for (let apiName of Object.keys(apisGuruList)) { let apiInfo = apisGuruList[apiName].versions[apisGuruList[apiName].preferred]; let url = apiInfo.swaggerUrl;