Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 4dcea96

Browse files
Foxandxsswardbell
authored andcommitted
chore: better protractor task
closes #1641
1 parent ffbdcd2 commit 4dcea96

File tree

7 files changed

+64
-12
lines changed

7 files changed

+64
-12
lines changed

gulpfile.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ var _exampleProtractorBoilerplateFiles = [
8989
'tsconfig.json'
9090
];
9191

92+
var _exampleConfigFilename = 'example-config.json';
93+
9294
/**
9395
* Run Protractor End-to-End Specs for Doc Samples
9496
* Alias for 'run-e2e-tests'
@@ -221,18 +223,19 @@ function findAndRunE2eTests(filter, outputFile) {
221223
// fileName; then shut down the example. All protractor output is appended
222224
// to the outputFile.
223225
function runE2eTsTests(appDir, outputFile) {
224-
// spawn tasks to start the app
225-
var appBuildSpawnInfo;
226-
var appRunSpawnInfo;
227-
228-
if (fs.existsSync(path.join(appDir, 'angular-cli.json'))) {
229-
appBuildSpawnInfo = spawnExt('npm', ['run', 'build:cli'], { cwd: appDir });
230-
appRunSpawnInfo = spawnExt('npm', ['run', 'http-server:cli', '--', '-s'], { cwd: appDir });
231-
} else {
232-
appBuildSpawnInfo = spawnExt('npm',['run','tsc'], { cwd: appDir });
233-
appRunSpawnInfo = spawnExt('npm',['run','http-server:e2e', '--', '-s' ], { cwd: appDir });
226+
// Grab protractor configuration or defaults to systemjs config.
227+
try {
228+
var exampleConfig = fs.readJsonSync(`${appDir}/${_exampleConfigFilename}`);
229+
} catch (e) {
230+
exampleConfig = {
231+
build: 'tsc',
232+
run: 'http-server:e2e'
233+
};
234234
}
235235

236+
var appBuildSpawnInfo = spawnExt('npm', ['run', exampleConfig.build], { cwd: appDir });
237+
var appRunSpawnInfo = spawnExt('npm', ['run', exampleConfig.run, '--', '-s'], { cwd: appDir });
238+
236239
return runProtractor(appBuildSpawnInfo.promise, appDir, appRunSpawnInfo, outputFile);
237240
}
238241

@@ -841,7 +844,7 @@ function getTypingsPaths(basePath) {
841844

842845
function getExamplePaths(basePath, includeBase) {
843846
// includeBase defaults to false
844-
return getPaths(basePath, "example-config.json", includeBase)
847+
return getPaths(basePath, _exampleConfigFilename, includeBase)
845848
}
846849

847850
function getDartExampleWebPaths(basePath) {

public/docs/_examples/cli-quickstart/ts/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ Thumbs.db
3636
!config/karma.conf.js
3737
!config/protractor.conf.js
3838
!src/typings.d.ts
39+
!src/tsconfig.json
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"build": "build:cli",
3+
"run": "http-server:cli"
4+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"compileOnSave": false,
3+
"compilerOptions": {
4+
"declaration": false,
5+
"emitDecoratorMetadata": true,
6+
"experimentalDecorators": true,
7+
"module": "commonjs",
8+
"moduleResolution": "node",
9+
"noEmitOnError": true,
10+
"noImplicitAny": false,
11+
"outDir": "../dist/",
12+
"rootDir": ".",
13+
"sourceMap": true,
14+
"target": "es5",
15+
"inlineSources": true
16+
},
17+
18+
"files": [
19+
"main.ts",
20+
"typings.d.ts"
21+
]
22+
}

public/docs/_examples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"webdriver:update": "webdriver-manager update",
1919
"start:webpack": "webpack-dev-server --inline --progress --port 8080",
2020
"test:webpack": "karma start karma.webpack.conf.js",
21-
"build:webpack": "rimraf dist && webpack --config config/webpack.prod.js --progress --profile --bail",
21+
"build:webpack": "rimraf dist && webpack --config config/webpack.prod.js --bail",
2222
"build:cli": "ng build"
2323
},
2424
"keywords": [],
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/// <reference path="../_protractor/e2e.d.ts" />
2+
describe('QuickStart E2E Tests', function () {
3+
4+
let expectedMsg = 'Hello from Angular 2 App with Webpack';
5+
6+
beforeEach(function () {
7+
browser.get('');
8+
});
9+
10+
it(`should display: ${expectedMsg}`, function () {
11+
expect(element(by.css('h1')).getText()).toEqual(expectedMsg);
12+
});
13+
14+
it('should display an image', function () {
15+
expect(element(by.css('img')).isPresent()).toBe(true);
16+
});
17+
18+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"build": "build:webpack",
3+
"run": "http-server:cli"
4+
}

0 commit comments

Comments
 (0)