diff --git a/.gitignore b/.gitignore index cc1f7647d..a2dc94736 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,4 @@ testem.log # System Files .DS_Store Thumbs.db +!/.protractor-smartrunner/ diff --git a/.travis.yml b/.travis.yml index bd2981dc8..a29a47f5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ node_js: cache: directories: - node_modules + - .protractor-smartrunner branches: only: diff --git a/angular.json b/angular.json index 208eadc3c..3586db867 100644 --- a/angular.json +++ b/angular.json @@ -266,7 +266,8 @@ "options": { "protractorConfig": "protractor.conf.js", "webdriverUpdate": false, - "devServerTarget": "app:lite-serve" + "devServerTarget": "app:lite-serve", + "invertGrep": true } }, "lint": { @@ -294,13 +295,13 @@ "options": { "tsConfig": "projects/adf-office-services-ext/tsconfig.lib.json", "project": "projects/adf-office-services-ext/ng-package.json" - } - , "configurations": { + }, + "configurations": { "production": { "tsConfig": "projects/adf-office-services-ext/tsconfig.lib.prod.json" } } -}, + }, "test": { "builder": "@angular-devkit/build-angular:karma", "options": { @@ -334,13 +335,13 @@ "options": { "tsConfig": "projects/aca-shared/tsconfig.lib.json", "project": "projects/aca-shared/ng-package.json" - } - , "configurations": { + }, + "configurations": { "production": { "tsConfig": "projects/aca-shared/tsconfig.lib.prod.json" } } -}, + }, "test": { "builder": "@angular-devkit/build-angular:karma", "options": { diff --git a/e2e/e2e-config/hooks/after-launch.js b/e2e/e2e-config/hooks/after-launch.js index 1931aeba8..b94538db5 100644 --- a/e2e/e2e-config/hooks/after-launch.js +++ b/e2e/e2e-config/hooks/after-launch.js @@ -2,7 +2,7 @@ const uploadOutput = require('../utils/upload-output'); const SAVE_SCREENSHOT = process.env.SAVE_SCREENSHOT === 'true'; -async function afterLaunch(statusCode) { +async function afterLaunch() { if (SAVE_SCREENSHOT) { console.log(`Save screenshot is ${SAVE_SCREENSHOT}, trying to save screenshots.`); diff --git a/protractor.conf.js b/protractor.conf.js index c6980bc5f..2d8dbb470 100755 --- a/protractor.conf.js +++ b/protractor.conf.js @@ -5,14 +5,15 @@ const path = require('path'); const { SpecReporter } = require('jasmine-spec-reporter'); const afterLaunch = require('./e2e/e2e-config/hooks/after-launch'); const fs = require('fs'); -require('dotenv').config(); +const resolve = require('path').resolve; + +require('dotenv').config({ path: process.env.ENV_FILE }); const SmartRunner = require('protractor-smartrunner'); const projectRoot = path.resolve(__dirname); const downloadFolder = `${projectRoot}/e2e-downloads`; const e2eFolder = path.resolve(projectRoot, 'e2e'); -const E2E_HOST = process.env.E2E_HOST || 'http://localhost'; -const E2E_PORT = process.env.E2E_PORT || 4200; +const E2E_HOST = process.env.E2E_HOST || 'http://localhost:4200'; const BROWSER_RUN = process.env.BROWSER_RUN; const width = 1366; const height = 768; @@ -129,7 +130,7 @@ exports.config = { directConnect: true, - baseUrl: `${E2E_HOST}${E2E_PORT ? `:${E2E_PORT}` : ''}`, + baseUrl: E2E_HOST, getPageTimeout: 50000, @@ -139,8 +140,8 @@ exports.config = { defaultTimeoutInterval: 100000, print: function() {}, ...SmartRunner.withOptionalExclusions( - path.resolve(__dirname, 'e2e/protractor.excludes.json') - ), + resolve(__dirname, './e2e/protractor.excludes.json'), + ) }, plugins: [ @@ -155,6 +156,10 @@ exports.config = { ], onPrepare() { + if (process.env.CI) { + SmartRunner.apply({repoHash: process.env.GIT_HASH || ''}); + } + const tsConfigPath = path.resolve(e2eFolder, 'tsconfig.e2e.json'); const tsConfig = require(tsConfigPath);