diff --git a/.travis.yml b/.travis.yml index 3b29f9c..6de1796 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,12 @@ script: - ./publish-to-gh-pages.sh after_success: - npm run codecov + - npm run e2e -- --ci --build-id=$TRAVIS_BUILD_NUMBER env: global: - GitHub_REF: github.com/PinkyJie/angular1-webpack-starter.git - - secure: "Sq6NJGdO4trRXiY+pr8RMV8GuZjsML8If6653ZKVqsHPFPS8eTEKNlIepXcWf/+I6cqVhiT0B/IUxVwdbw/Jh+0BLM1RxofvyFAcZAQaxhRnfDnVdGqysP89RlxuoR/Bc58F7qFwu4nfJ96dFfiIDEnV5whLbvekXperPeLDy41BbgRov4H2ifz3OiwAK2DISmM4ikJBCkwKOA0BHo9/cDtobHNicCM7sE36aYIjYXK6esM8aBZ/XHiLzF/rlfRGQFvNmaxq6Wu41GbtnatDg3PUqBIxCiutKpqEpPothGN/gbTZFNQBCJGmNqnp8KxD2ua3mBvmnL0x+Rij27uMFTfSqfDyLTx/A9M1tMYaIbwBNXz3tR7jyQk0WyAFbuTyw4i6rtM4qqRLSbkF3DXImM5qPqO5zlXNMSAAlOqDXWL9+PpU2U0S7YtxZiV5fzGuZ77F1XTsnHhTgNDru0l0mZhPzTfb+rnagcT74O/6XBeShEZ+eh9gfDLF0/uyXP4Jjif/7204M+Attk/GUuXht+A3+SttUJ/nGbvNJyUi1OXZonuRJSkEPvNu/88KyMvLP/QxTWo0UVE+2Vxb7p9MQo5Fl/W0cCTLQorJX/DYVkJErnktzHX0UV4Y0dR0pQKZpUcmkxkk2zQ/uLugVRD3oHw/Hnzbb3PWlPL5vosIsoE=" \ No newline at end of file + - secure: "Sq6NJGdO4trRXiY+pr8RMV8GuZjsML8If6653ZKVqsHPFPS8eTEKNlIepXcWf/+I6cqVhiT0B/IUxVwdbw/Jh+0BLM1RxofvyFAcZAQaxhRnfDnVdGqysP89RlxuoR/Bc58F7qFwu4nfJ96dFfiIDEnV5whLbvekXperPeLDy41BbgRov4H2ifz3OiwAK2DISmM4ikJBCkwKOA0BHo9/cDtobHNicCM7sE36aYIjYXK6esM8aBZ/XHiLzF/rlfRGQFvNmaxq6Wu41GbtnatDg3PUqBIxCiutKpqEpPothGN/gbTZFNQBCJGmNqnp8KxD2ua3mBvmnL0x+Rij27uMFTfSqfDyLTx/A9M1tMYaIbwBNXz3tR7jyQk0WyAFbuTyw4i6rtM4qqRLSbkF3DXImM5qPqO5zlXNMSAAlOqDXWL9+PpU2U0S7YtxZiV5fzGuZ77F1XTsnHhTgNDru0l0mZhPzTfb+rnagcT74O/6XBeShEZ+eh9gfDLF0/uyXP4Jjif/7204M+Attk/GUuXht+A3+SttUJ/nGbvNJyUi1OXZonuRJSkEPvNu/88KyMvLP/QxTWo0UVE+2Vxb7p9MQo5Fl/W0cCTLQorJX/DYVkJErnktzHX0UV4Y0dR0pQKZpUcmkxkk2zQ/uLugVRD3oHw/Hnzbb3PWlPL5vosIsoE=" +addons: + sauce_connect: + username: "sd4399340" + access_key: "5829a37c-41c0-4490-b6c2-061ae4acc5e9" \ No newline at end of file diff --git a/karma.config.js b/karma.config.js index c6022aa..7899702 100644 --- a/karma.config.js +++ b/karma.config.js @@ -6,7 +6,7 @@ const unitTestEntry = 'source/test/unit/helper.js'; // run multiple times in watch mode const singleRun = !args.watch; // use phantomjs in watch mode -const browser = (args.watch || args.travis) ? 'PhantomJS' : 'Chrome'; +const browser = (args.watch || args.ci) ? 'PhantomJS' : 'Chrome'; // load babel polyfill for phantomjs const files = browser === 'PhantomJS' ? [ 'node_modules/babel-core/browser-polyfill.js', diff --git a/protractor.config.js b/protractor.config.js index db55959..12e888f 100644 --- a/protractor.config.js +++ b/protractor.config.js @@ -2,11 +2,11 @@ const HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter' const SpecReporter = require('jasmine-spec-reporter'); const webpackConfig = require('./webpack.config'); +const args = require('yargs').argv; const e2eBaseFolder = './source/test/e2e'; -exports.config = { - baseUrl: `http://${webpackConfig.devServer.host}:${webpackConfig.devServer.port}`, +const config = { framework: 'jasmine2', jasmineNodeOpts: { showColors: true, @@ -15,9 +15,6 @@ exports.config = { print: () => {} }, specs: `${e2eBaseFolder}/specs/*.spec.js`, - capabilities: { - browserName: 'chrome' - }, onPrepare: () => { // support ES6, need to put this line in onPrepare to make line number // in error report correct @@ -51,3 +48,56 @@ exports.config = { timeout: 10000 } }; + +if (args.ci) { + // run by sauce lab + config.seleniumAddress = 'http://sd4399340:5829a37c-41c0-4490-b6c2-061ae4acc5e9@ondemand.saucelabs.com/wd/hub'; + // https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/ + config.multiCapabilities = [ + { + name: `chrome-on-windows-${args.buildId}`, + build: args.buildId, + browserName: 'chrome', + platform: 'Windows 7' + }, + { + name: `safari-on-mac-${args.buildId}`, + build: args.buildId, + browserName: 'safari', + platform: 'OS X 10.11' + }, + { + name: `ie9-on-windows-${args.buildId}`, + build: args.buildId, + browserName: 'internet explorer', + platform: 'Windows 7', + version: '9.0' + }, + { + name: `safari-on-iphone-${args.buildId}`, + build: args.buildId, + browserName: 'iphone', + platform: 'OS X 10.10', + version: '9.1', + deviceName: 'iPhone 5s', + deviceOrientation: 'portrait' + }, + { + name: `chrome-on-andoird-${args.buildId}`, + build: args.buildId, + browserName: 'android', + platform: 'Linux', + version: '4.4', + deviceName: 'Android Emulator', + deviceOrientation: 'portrait' + } + ]; +} else { + // local run + config.baseUrl = `http://${webpackConfig.devServer.host}:${webpackConfig.devServer.port}/`; + config.capabilities = { + browserName: 'chrome' + }; +} + +exports.config = config; diff --git a/publish-to-gh-pages.sh b/publish-to-gh-pages.sh index 903b154..dacd71a 100755 --- a/publish-to-gh-pages.sh +++ b/publish-to-gh-pages.sh @@ -2,7 +2,7 @@ set -ev # run unit test (--travis: use phantomjs browser) -npm test -- --travis +npm test -- --ci # apply /#/ style router for SPA git apply ./gh-pages-patch.diff diff --git a/source/test/e2e/helper.js b/source/test/e2e/helper.js index ed0c208..ee38a08 100644 --- a/source/test/e2e/helper.js +++ b/source/test/e2e/helper.js @@ -140,7 +140,7 @@ class BasePageObject { const homeItem = breadcrumb.homeItem; expect(homeItem.view.isDisplayed()).toBe(true); expect(homeItem.view.$(homeItem.link).getAttribute('href')) - .toEqual(`${browser.baseUrl}/`); + .toEqual(`${browser.baseUrl}`); expect(homeItem.view.$(homeItem.icon)).toHaveClass('mdi-action-home'); // items expect(breadcrumb.breadcrumbItem.view.count()).toEqual(expectedBreadcrumbItems.length); @@ -168,7 +168,7 @@ class BasePageObject { class E2EHelper { gotoUrl (url) { - browser.get(`${browser.baseUrl}/${url}`); + browser.get(`${browser.baseUrl}${url}`); } chooseDate (input, picker, date) {