diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e4b91a3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +/.git +/.nyc_output +/.tmp +/node_modules +/reports +/REPORTS2 +/coverage.lcov diff --git a/.travis.yml b/.travis.yml index c45cd66..a2963a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,27 +1,10 @@ language: node_js node_js: - "node" -sudo: required -dist: trusty -addons: - firefox: latest - apt: - sources: - - google-chrome - packages: - - google-chrome-stable - - graphicsmagick - -before_script: - - export CHROME_BIN=/usr/bin/google-chrome - - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start - - npm run setup - - nohup bash -c "npm run server &> selenium-server.log &" - - sleep 10 -after_success: - - npm run coverage - - npm run lint +services: + - docker +script: + - docker-compose run --rm --use-aliases app deploy: provider: npm email: andrej@chocolatejar.eu diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4f75baf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +# Use the latest one as this is for CI purpose. +FROM node:latest + +WORKDIR /app + +RUN apt-get update \ + && apt-get install -y --no-install-recommends graphicsmagick \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY package.json . +COPY package-lock.json . + +RUN npm install diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..c9a4aa3 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,65 @@ +version: '2' +services: + app: + build: + context: . + volumes: + - .:/app + - /app/node_modules + working_dir: /app + environment: + - SELENIUM_URL=http://selenium:4444/wd/hub + # To have report.ci defined + - TRAVIS=1 + - TRAVIS_JOB_NUMBER=dummy + - TRAVIS_BRANCH=dummy + - TRAVIS_COMMIT=dummy + - TRAVIS_TAG=dummy + - TRAVIS_REPO_SLUG=dummy + - TRAVIS_COMMIT_MESSAGE=dummy + - TRAVIS_BUILD_ID=dummy + command: + - /bin/sh + - -x + - -e + - -c + - | + sleep 10 + npm test + npm run coverage + npm run lint + depends_on: + - firefox + - chrome + networks: + - default + selenium: + image: selenium/hub + ports: + - 4444 + networks: + - default + firefox: + image: selenium/node-firefox + volumes: + - /dev/shm:/dev/shm + depends_on: + - selenium + environment: + - HUB_HOST=selenium + networks: + - default + chrome: + image: selenium/node-chrome + volumes: + - /dev/shm:/dev/shm + depends_on: + - selenium + environment: + - HUB_HOST=selenium + # https://github.com/SeleniumHQ/docker-selenium/issues/87 + - DBUS_SESSION_BUS_ADDRESS=/dev/null + - NODE_MAX_INSTANCES=2 + - NODE_MAX_SESSION=2 + networks: + - default diff --git a/index.js b/index.js index 5d67c82..9b8fce3 100755 --- a/index.js +++ b/index.js @@ -447,7 +447,7 @@ protractorUtil.registerJasmineReporter = function(context) { prefix: '' }; global.browser.getProcessedConfig().then(function(config) { - if(config.capabilities) { + if (config.capabilities) { protractorUtil.test.prefix = '[' + config.capabilities.name + '] '; } protractorUtil.testResults.push(protractorUtil.test); @@ -457,7 +457,7 @@ protractorUtil.registerJasmineReporter = function(context) { protractorUtil.takeOnSpecDone(result, context, protractorUtil.test); //exec async operation //Add defined name to the test.description as a prefix - if(context.config.addPrefixToTests) { + if (context.config.addPrefixToTests) { result.description = protractorUtil.test.prefix + result.description; result.fullName = protractorUtil.test.prefix + result.fullName; } diff --git a/spec/integrational/protractor-config/bug55.js b/spec/integrational/protractor-config/bug55.js index eebdd99..76dd88d 100644 --- a/spec/integrational/protractor-config/bug55.js +++ b/spec/integrational/protractor-config/bug55.js @@ -4,7 +4,6 @@ exports.config = { seleniumAddress: env.seleniumAddress, framework: 'jasmine2', specs: ['../protractor/angularjs-homepage-disabled-test.js'], - useBlockingProxy: true, plugins: [{ path: '../../../index.js', screenshotPath: '.tmp/bug55', diff --git a/spec/integrational/protractor-config/failuresWithLogs.js b/spec/integrational/protractor-config/failuresWithLogs.js index 356be00..885a85e 100644 --- a/spec/integrational/protractor-config/failuresWithLogs.js +++ b/spec/integrational/protractor-config/failuresWithLogs.js @@ -8,6 +8,10 @@ exports.config = { browserName: env.capabilities.browserName, loggingPrefs: { browser: 'ALL' // "OFF", "SEVERE", "WARNING", "INFO", "CONFIG", "FINE", "FINER", "FINEST", "ALL". + }, + // For chrome 75+ + 'goog:loggingPrefs': { + browser: 'ALL' } }, plugins: [{ diff --git a/spec/integrational/protractor-config/failuresWithLogsAsap.js b/spec/integrational/protractor-config/failuresWithLogsAsap.js index 3308f58..48e5da4 100644 --- a/spec/integrational/protractor-config/failuresWithLogsAsap.js +++ b/spec/integrational/protractor-config/failuresWithLogsAsap.js @@ -8,6 +8,10 @@ exports.config = { browserName: env.capabilities.browserName, loggingPrefs: { browser: 'ALL' // "OFF", "SEVERE", "WARNING", "INFO", "CONFIG", "FINE", "FINER", "FINEST", "ALL". + }, + // For chrome 75+ + 'goog:loggingPrefs': { + browser: 'ALL' } }, plugins: [{ diff --git a/spec/integrational/protractor-config/verbose.js b/spec/integrational/protractor-config/verbose.js index 1f22298..db848e1 100644 --- a/spec/integrational/protractor-config/verbose.js +++ b/spec/integrational/protractor-config/verbose.js @@ -4,7 +4,6 @@ exports.config = { seleniumAddress: env.seleniumAddress, framework: 'jasmine2', specs: ['../protractor/angularjs-homepage-disabled-test.js'], - useBlockingProxy: true, plugins: [{ path: '../../../index.js', screenshotPath: '.tmp/verbose', diff --git a/spec/integrational/screenshoter.int.spec.js b/spec/integrational/screenshoter.int.spec.js index 6dad3d0..5fd92a1 100644 --- a/spec/integrational/screenshoter.int.spec.js +++ b/spec/integrational/screenshoter.int.spec.js @@ -1537,18 +1537,18 @@ describe("Screenshoter running under protractor", function() { var report = getReportAsJson(data); //Since we can't guarantee which one of the test-specs will end up firts, I've to do a matcher validation between "M" and "L" letters. - expect(report.tests[0].description).toMatch('\[[M|L]\] should greet the named user'); - expect(report.tests[0].fullName).toMatch('\[[M|L]\] angularjs homepage should greet the named user'); - expect(report.tests[1].description).toMatch('\[[M|L]\] should list todos'); - expect(report.tests[1].fullName).toMatch('\[[M|L]\] angularjs homepage todo list should list todos'); - expect(report.tests[2].description).toMatch('\[[M|L]\] should add a todo'); - expect(report.tests[2].fullName).toMatch('\[[M|L]\] angularjs homepage todo list should add a todo'); - expect(report.tests[3].description).toMatch('\[[M|L]\] should greet the named user'); - expect(report.tests[3].fullName).toMatch('\[[M|L]\] angularjs homepage should greet the named user'); - expect(report.tests[4].description).toMatch('\[[M|L]\] should list todos'); - expect(report.tests[4].fullName).toMatch('\[[M|L]\] angularjs homepage todo list should list todos'); - expect(report.tests[5].description).toMatch('\[[M|L]\] should add a todo'); - expect(report.tests[5].fullName).toMatch('\[[M|L]\] angularjs homepage todo list should add a todo'); + expect(report.tests[0].description).toMatch('\\[[M|L]\\] should greet the named user'); + expect(report.tests[0].fullName).toMatch('\\[[M|L]\\] angularjs homepage should greet the named user'); + expect(report.tests[1].description).toMatch('\\[[M|L]\\] should list todos'); + expect(report.tests[1].fullName).toMatch('\\[[M|L]\\] angularjs homepage todo list should list todos'); + expect(report.tests[2].description).toMatch('\\[[M|L]\\] should add a todo'); + expect(report.tests[2].fullName).toMatch('\\[[M|L]\\] angularjs homepage todo list should add a todo'); + expect(report.tests[3].description).toMatch('\\[[M|L]\\] should greet the named user'); + expect(report.tests[3].fullName).toMatch('\\[[M|L]\\] angularjs homepage should greet the named user'); + expect(report.tests[4].description).toMatch('\\[[M|L]\\] should list todos'); + expect(report.tests[4].fullName).toMatch('\\[[M|L]\\] angularjs homepage todo list should list todos'); + expect(report.tests[5].description).toMatch('\\[[M|L]\\] should add a todo'); + expect(report.tests[5].fullName).toMatch('\\[[M|L]\\] angularjs homepage todo list should add a todo'); done(); }); diff --git a/spec/unit/screenshoter.unit.spec.js b/spec/unit/screenshoter.unit.spec.js index be3b8fe..005375f 100644 --- a/spec/unit/screenshoter.unit.spec.js +++ b/spec/unit/screenshoter.unit.spec.js @@ -128,14 +128,14 @@ describe("Screenshoter unit", function() { it("should merge user config", function() { screenshoter.config = { - screenshotPath: 'REPORTS', + screenshotPath: 'REPORTS2', screenshotOnSpec: 'failure' }; screenshoter.setup(); expect(screenshoter.config.reportFile).toBeDefined(); delete screenshoter.config.reportFile; expect(screenshoter.config).toEqual({ - screenshotPath: 'REPORTS', + screenshotPath: 'REPORTS2', withLogs: true, screenshotOnExpect: 'failure+success', screenshotOnSpec: 'failure',