Skip to content

feat(protractor): add e2e tests in CI #837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
May 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ env:

cache:
directories: node_modules

script:
- npm run tests.all
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version: "{build}"

# Test against this version of Node.js
environment:
nodejs_version: "4.1.0"
nodejs_version: "Stable"
# https://github.com/DefinitelyTyped/tsd#tsdrc
# Token has no scope (read-only access to public information)
TSD_GITHUB_TOKEN: "9b18c72997769f3867ef2ec470e626d39661795d"
Expand All @@ -32,8 +32,7 @@ test_script:
# We test multiple Windows shells because of prior stdout buffering issues
# filed against Grunt. https://github.com/joyent/node/issues/3584
- ps: "npm --version # PowerShell" # Pass comment to PS for easier debugging
- npm test

- npm run tests.all

notifications:
- provider: Webhook
Expand All @@ -42,3 +41,4 @@ notifications:
on_build_failure: true
on_build_status_changed: true

cache: node_modules
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"gulp": "gulp",
"karma": "karma",
"karma.start": "karma start",
"postinstall": "typings install && gulp check.versions && npm prune",
"postinstall": "typings install && gulp check.versions && npm prune && gulp webdriver",
"reinstall": "npm cache clean && npm install",
"serve.coverage": "remap-istanbul -b src/ -i coverage/coverage-final.json -o coverage -t html && npm run gulp -- serve.coverage --color",
"serve.dev": "gulp serve.dev --color",
Expand All @@ -29,6 +29,8 @@
"start": "gulp serve.dev --color",
"tasks.list": "gulp --tasks-simple --color",
"test": "gulp test --color",
"e2e": "gulp build.prod --color && gulp build.js.e2e --color && gulp e2e --color",
"tests.all": "npm test && npm run e2e",
"webdriver-start": "webdriver-manager start",
"webdriver-update": "webdriver-manager update"
},
Expand All @@ -53,13 +55,16 @@
"extend": "^3.0.0",
"gulp": "^3.9.1",
"gulp-cached": "^1.1.0",
"gulp-clean-css": "^2.0.7",
"gulp-concat": "^2.6.0",
"gulp-concat-css": "^2.2.0",
"gulp-filter": "^4.0.0",
"gulp-inject": "^4.0.0",
"gulp-inline-ng2-template": "^1.1.2",
"gulp-load-plugins": "^1.2.0",
"gulp-plumber": "~1.1.0",
"gulp-postcss": "^6.1.0",
"gulp-protractor": "^2.3.0",
"gulp-shell": "~0.5.2",
"gulp-sourcemaps": "2.0.0-alpha",
"gulp-template": "^4.0.0",
Expand All @@ -69,8 +74,6 @@
"gulp-uglify": "^1.5.3",
"gulp-util": "^3.0.7",
"gulp-watch": "^4.3.5",
"gulp-concat-css": "^2.2.0",
"gulp-clean-css": "^2.0.7",
"is-ci": "^1.0.8",
"isstream": "^0.1.2",
"jasmine-core": "~2.4.1",
Expand Down
32 changes: 21 additions & 11 deletions protractor.conf.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
exports.config = {
baseUrl: 'http://localhost:5555',
const config = {
baseUrl: 'http://localhost:5555/',

specs: [
'dist/dev/**/*.e2e.js'
'./dist/dev/**/*.e2e.js'
],

exclude: [],

framework: 'jasmine2',
// 'jasmine' by default will use the latest jasmine framework
framework: 'jasmine',

allScriptsTimeout: 110000,
// allScriptsTimeout: 110000,

jasmineNodeOpts: {
showTiming: true,
// showTiming: true,
showColors: true,
isVerbose: false,
includeStackTrace: false,
defaultTimeoutInterval: 400000
// defaultTimeoutInterval: 400000
},

directConnect: true,

capabilities: {
'browserName': 'chrome'
browserName: 'chrome'
},

onPrepare: function() {
var SpecReporter = require('jasmine-spec-reporter');
const SpecReporter = require('jasmine-spec-reporter');
// add jasmine spec reporter
jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: true}));
jasmine.getEnv().addReporter(new SpecReporter({ displayStacktrace: true }));

browser.ignoreSynchronization = false;
},
Expand All @@ -37,7 +40,14 @@ exports.config = {
*
* useAllAngular2AppRoots: tells Protractor to wait for any angular2 apps on the page instead of just the one matching
* `rootEl`
*
*/
useAllAngular2AppRoots: true
};

if (process.env.TRAVIS) {
config.capabilities = {
browserName: 'firefox'
};
}

exports.config = config;
3 changes: 1 addition & 2 deletions src/client/app/+about/components/about.component.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
describe('About', () => {
beforeEach(() => {
browser.get('/');
browser.waitForAngular();
element.all(by.css('nav > a')).get(1).click();
});

it('should have correct feature heading', () => {
let el = element(by.css('sd-app sd-about h2'));
let el = element(by.css('sd-about h2'));
expect(el.getText()).toEqual('Features');
});
});
2 changes: 1 addition & 1 deletion src/client/app/+home/components/home.component.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe('Home', () => {

beforeEach( () => {
browser.get('');
browser.get('/');
});

it('should have an input', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/client/app/components/app.component.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe('App', () => {

beforeEach( () => {
browser.get('');
browser.get('/');
});

it('should have a title', () => {
Expand Down
27 changes: 27 additions & 0 deletions tools/tasks/seed/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as gulp from 'gulp';
import * as express from 'express';
import { protractor } from 'gulp-protractor';

class Protractor {
server(port: number, dir: string) {
let app = express();
app.use(express.static(dir));
return new Promise((resolve, reject) => {
let server = app.listen(port, () => {
resolve(server);
});
});
}
}

export = (done: any) => {
new Protractor()
.server(5555, './dist/prod')
.then((server: any) => {
gulp
.src('./dist/dev/**/*.e2e.js')
.pipe(protractor({ configFile: 'protractor.conf.js' }))
.on('error', (error: string) => { throw error; })
.on('end', () => { server.close(done); });
});
};
3 changes: 3 additions & 0 deletions tools/tasks/seed/webdriver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { webdriver_update } from 'gulp-protractor';

export = webdriver_update;
1 change: 1 addition & 0 deletions typings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"glob": "github:DefinitelyTyped/DefinitelyTyped/glob/glob.d.ts#5c3e47967affa3c4128a3875d1664ba206ae1b0f",
"gulp": "github:DefinitelyTyped/DefinitelyTyped/gulp/gulp.d.ts#5c3e47967affa3c4128a3875d1664ba206ae1b0f",
"gulp-load-plugins": "github:DefinitelyTyped/DefinitelyTyped/gulp-load-plugins/gulp-load-plugins.d.ts#e081148d88b857d66509e3b46edbd08b3f75f96a",
"gulp-protractor": "registry:dt/gulp-protractor#1.0.0+20160316155526",
"gulp-shell": "github:DefinitelyTyped/DefinitelyTyped/gulp-shell/gulp-shell.d.ts#5c3e47967affa3c4128a3875d1664ba206ae1b0f",
"gulp-util": "github:DefinitelyTyped/DefinitelyTyped/gulp-util/gulp-util.d.ts#5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff",
"jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#26c98c8a9530c44f8c801ccc3b2057e2101187ee",
Expand Down