Skip to content

Commit e2e4f56

Browse files
committed
feat(e2e): add ng e2e command
1 parent 0228140 commit e2e4f56

File tree

10 files changed

+69
-32
lines changed

10 files changed

+69
-32
lines changed

README.md

+4-7
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,13 @@ Tests will execute after a build is executed via [Karma](http://karma-runner.git
152152

153153
### Running end-to-end tests
154154

155-
Before running the tests make sure that you have an updated webdriver and that
156-
the tests are built:
157-
158155
```bash
159-
$(npm bin)/webdriver-manager update
160-
$(npm bin)/tsc -p e2e/
156+
ng e2e
161157
```
162158

163-
Afterwards you only need to run `$(npm bin)/protractor` while serving via
164-
`ng serve`.
159+
Before running the tests make sure you are serving the app via `ng serve`.
160+
161+
End-to-end tests are ran via [Protractor](https://angular.github.io/protractor/).
165162

166163

167164
### Deploying the app via GitHub Pages

addon/ng2/blueprints/ng2/files/e2e/app.e2e.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import "angular2/testing";
1+
/// <reference path="../typings/main.d.ts" />
2+
23
import { <%= jsComponentName %>Page } from './app.po';
34

45
describe('<%= htmlComponentName %> App', function() {

addon/ng2/blueprints/ng2/files/e2e/app.po.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import "angular2/testing";
2-
31
export class <%= jsComponentName %>Page {
42
navigateTo() { return browser.get('/'); }
53
getParagraphText() { return element(by.css('<%= jsComponentName %>-app p')).getText(); }
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
{
22
"compilerOptions": {
3-
"target": "ES5",
4-
"module": "commonjs",
5-
"sourceMap": true,
63
"declaration": false,
74
"emitDecoratorMetadata": true,
85
"experimentalDecorators": true,
9-
"removeComments": false
6+
"mapRoot": "",
7+
"module": "system",
8+
"moduleResolution": "node",
9+
"noEmitOnError": true,
10+
"noImplicitAny": false,
11+
"rootDir": ".",
12+
"sourceMap": true,
13+
"sourceRoot": "/",
14+
"target": "es5"
1015
}
1116
}

addon/ng2/blueprints/ng2/files/package.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"start": "ng server",
1313
"postinstall": "typings install --ambient",
1414
"lint": "tslint src/**/*.ts",
15-
"format": "clang-format -i -style=file --glob=src/**/*.ts"
15+
"format": "clang-format -i -style=file --glob=src/**/*.ts",
16+
"pree2e": "webdriver-manager update",
17+
"e2e": "protractor"
1618
},
1719
"private": true,
1820
"dependencies": {
@@ -30,12 +32,14 @@
3032
"ember-cli-inject-live-reload": "^1.3.0",
3133
"glob": "^6.0.4",
3234
"jasmine-core": "^2.3.4",
35+
"jasmine-spec-reporter": "^2.4.0",
3336
"karma": "^0.13.15",
3437
"karma-chrome-launcher": "^0.2.1",
3538
"karma-jasmine": "^0.3.6",
3639
"protractor": "^3.0.0",
3740
"tslint": "^3.3.0",
3841
"typescript": "^1.7.3",
39-
"typings": "^0.6.6"
42+
"typings": "^0.6.6",
43+
"ts-node": "^0.5.5"
4044
}
4145
}
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
1+
var SpecReporter = require('jasmine-spec-reporter');
2+
13
exports.config = {
24
allScriptsTimeout: 11000,
3-
45
specs: [
5-
'e2e/**/*.e2e.js'
6+
'e2e/**/*.e2e.ts'
67
],
7-
88
capabilities: {
99
'browserName': 'chrome'
1010
},
11-
1211
directConnect: true,
13-
1412
baseUrl: 'http://localhost:4200/',
15-
1613
framework: 'jasmine',
17-
1814
jasmineNodeOpts: {
19-
defaultTimeoutInterval: 30000
15+
showColors: true,
16+
defaultTimeoutInterval: 30000,
17+
print: function() {}
2018
},
21-
2219
useAllAngular2AppRoots: true,
23-
2420
beforeLaunch: function() {
25-
require('zone.js');
26-
require('reflect-metadata');
27-
}
21+
require('ts-node/register');
22+
},
23+
onPrepare: function() {
24+
jasmine.getEnv().addReporter(new SpecReporter());
25+
},
2826
};

addon/ng2/blueprints/ng2/files/typings.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"dependencies": {},
3-
"devDependencies": {
4-
},
3+
"devDependencies": {},
54
"ambientDevDependencies": {
6-
"jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#26c98c8a9530c44f8c801ccc3b2057e2101187ee"
5+
"angular-protractor": "github:DefinitelyTyped/DefinitelyTyped/angular-protractor/angular-protractor.d.ts#17fa1e5f269189f7f8e0f53f8c443e6c2eac562c",
6+
"jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#26c98c8a9530c44f8c801ccc3b2057e2101187ee",
7+
"selenium-webdriver": "github:DefinitelyTyped/DefinitelyTyped/selenium-webdriver/selenium-webdriver.d.ts#a83677ed13add14c2ab06c7325d182d0ba2784ea"
78
},
89
"ambientDependencies": {
910
"es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#6697d6f7dadbf5773cb40ecda35a76027e0783b2"

addon/ng2/commands/e2e.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* jshint node: true */
2+
'use strict';
3+
4+
var Command = require('ember-cli/lib/models/command');
5+
var E2ETask = require('../tasks/e2e');
6+
7+
module.exports = Command.extend({
8+
name: 'e2e',
9+
description: 'Run e2e tests in existing project',
10+
works: 'insideProject',
11+
run: function() {
12+
var e2eTask = new E2ETask({
13+
ui: this.ui,
14+
analytics: this.analytics,
15+
project: this.project
16+
});
17+
18+
return e2eTask.run();
19+
}
20+
});

addon/ng2/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = {
1010
'install' : require('./commands/install'),
1111
'uninstall' : require('./commands/uninstall'),
1212
'test' : require('./commands/test'),
13+
'e2e' : require('./commands/e2e'),
1314
'lint' : require('./commands/lint'),
1415
'format' : require('./commands/format')
1516
};

addon/ng2/tasks/e2e.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* jshint node: true */
2+
'use strict';
3+
4+
var Promise = require('ember-cli/lib/ext/promise');
5+
var Task = require('ember-cli/lib/models/task');
6+
var exec = Promise.denodeify(require('shelljs').exec);
7+
8+
module.exports = Task.extend({
9+
run: function() {
10+
return exec('npm run e2e');
11+
}
12+
});

0 commit comments

Comments
 (0)