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

Commit 5042b30

Browse files
filipesilvawardbell
authored andcommitted
chore(test): add protractor4 (#2233)
* chore(test): add protractor4 * fix lint, remove boilerplate files, fix less gen * separate scripts between package.json * ignore a2docs.css in boilerplate * remove tslint in _examples
1 parent 7c98d16 commit 5042b30

File tree

97 files changed

+463
-12826
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+463
-12826
lines changed

gulpfile.js

+18-38
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ var TEMP_PATH = './_temp';
3737
var DOCS_PATH = path.join(PUBLIC_PATH, 'docs');
3838

3939
var EXAMPLES_PATH = path.join(DOCS_PATH, '_examples');
40-
var EXAMPLES_PROTRACTOR_PATH = path.join(EXAMPLES_PATH, '_protractor');
40+
var BOILERPLATE_PATH = path.join(EXAMPLES_PATH, '_boilerplate');
4141
var EXAMPLES_TESTING_PATH = path.join(EXAMPLES_PATH, 'testing/ts');
4242
var NOT_API_DOCS_GLOB = path.join(PUBLIC_PATH, './{docs/*/latest/!(api),!(docs)}/**/*.*');
4343
var RESOURCES_PATH = path.join(PUBLIC_PATH, 'resources');
@@ -92,22 +92,16 @@ var _excludeMatchers = _excludePatterns.map(function(excludePattern){
9292
});
9393

9494
var _exampleBoilerplateFiles = [
95-
'.editorconfig',
9695
'a2docs.css',
9796
'package.json',
9897
'styles.css',
9998
'systemjs.config.js',
10099
'tsconfig.json',
101-
'tslint.json',
102-
'typings.json'
100+
'tslint.json'
103101
];
104102

105103
var _exampleDartWebBoilerPlateFiles = ['a2docs.css', 'styles.css'];
106104

107-
var _exampleProtractorBoilerplateFiles = [
108-
'tsconfig.json'
109-
];
110-
111105
var _exampleUnitTestingBoilerplateFiles = [
112106
'karma-test-shim.js',
113107
'karma.conf.js'
@@ -205,18 +199,13 @@ function runE2e() {
205199
});
206200
*/
207201
// Not 'fast'; do full setup
208-
gutil.log('runE2e: install _protractor stuff');
209-
var spawnInfo = spawnExt('npm', ['install'], { cwd: EXAMPLES_PROTRACTOR_PATH});
202+
gutil.log('runE2e: install _examples stuff');
203+
var spawnInfo = spawnExt('npm', ['install'], { cwd: EXAMPLES_PATH});
210204
promise = spawnInfo.promise
211-
.then(function() {
212-
gutil.log('runE2e: install _examples stuff');
213-
spawnInfo = spawnExt('npm', ['install'], { cwd: EXAMPLES_PATH})
214-
return spawnInfo.promise;
215-
})
216205
.then(function() {
217206
buildStyles(copyExampleBoilerplate, _.noop);
218207
gutil.log('runE2e: update webdriver');
219-
spawnInfo = spawnExt('npm', ['run', 'webdriver:update'], {cwd: EXAMPLES_PROTRACTOR_PATH});
208+
spawnInfo = spawnExt('npm', ['run', 'webdriver:update'], {cwd: EXAMPLES_PATH});
220209
return spawnInfo.promise;
221210
});
222211
};
@@ -251,11 +240,10 @@ function findAndRunE2eTests(filter, outputFile) {
251240
fs.writeFileSync(outputFile, header);
252241

253242
// create an array of combos where each
254-
// combo consists of { examplePath: ... , protractorConfigFilename: ... }
243+
// combo consists of { examplePath: ... }
255244
var examplePaths = [];
256245
var e2eSpecPaths = getE2eSpecPaths(EXAMPLES_PATH);
257246
e2eSpecPaths.forEach(function(specPath) {
258-
var destConfig = path.join(specPath, 'protractor.config.js');
259247
// get all of the examples under each dir where a pcFilename is found
260248
localExamplePaths = getExamplePaths(specPath, true);
261249
// Filter by language
@@ -326,7 +314,7 @@ function runProtractor(prepPromise, appDir, appRunSpawnInfo, outputFile) {
326314
// start protractor
327315

328316
var spawnInfo = spawnExt('npm', [ 'run', 'protractor', '--', 'protractor.config.js',
329-
`--specs=${specFilename}`, '--params.appDir=' + appDir, '--params.outputFile=' + outputFile], { cwd: EXAMPLES_PROTRACTOR_PATH });
317+
`--specs=${specFilename}`, '--params.appDir=' + appDir, '--params.outputFile=' + outputFile], { cwd: EXAMPLES_PATH });
330318

331319
spawnInfo.proc.stderr.on('data', function (data) {
332320
transpileError = transpileError || /npm ERR! Exit status 100/.test(data.toString());
@@ -477,7 +465,7 @@ gulp.task('_copy-example-boilerplate', function (done) {
477465
function buildStyles(cb, done){
478466
gulp.src(path.join(STYLES_SOURCE_PATH, _styleLessName))
479467
.pipe(less())
480-
.pipe(gulp.dest(EXAMPLES_PATH)).on('end', function(){
468+
.pipe(gulp.dest(BOILERPLATE_PATH)).on('end', function(){
481469
cb().then(function() { done(); });
482470
});
483471
}
@@ -488,12 +476,12 @@ function buildStyles(cb, done){
488476
function copyExampleBoilerplate() {
489477
gutil.log('Copying example boilerplate files');
490478
var sourceFiles = _exampleBoilerplateFiles.map(function(fn) {
491-
return path.join(EXAMPLES_PATH, fn);
479+
return path.join(BOILERPLATE_PATH, fn);
492480
});
493481
var examplePaths = excludeDartPaths(getExamplePaths(EXAMPLES_PATH));
494482

495483
var dartWebSourceFiles = _exampleDartWebBoilerPlateFiles.map(function(fn){
496-
return path.join(EXAMPLES_PATH, fn);
484+
return path.join(BOILERPLATE_PATH, fn);
497485
});
498486
var dartExampleWebPaths = getDartExampleWebPaths(EXAMPLES_PATH);
499487

@@ -503,21 +491,17 @@ function copyExampleBoilerplate() {
503491
.then(function() {
504492
return copyFiles(dartWebSourceFiles, dartExampleWebPaths, destFileMode);
505493
})
506-
// copy certain files from _examples/_protractor dir to each subdir that contains an e2e-spec file.
507-
.then(function() {
508-
var protractorSourceFiles =
509-
_exampleProtractorBoilerplateFiles
510-
.map(function(name) {return path.join(EXAMPLES_PROTRACTOR_PATH, name); });
511-
var e2eSpecPaths = getE2eSpecPaths(EXAMPLES_PATH);
512-
return copyFiles(protractorSourceFiles, e2eSpecPaths, destFileMode);
513-
})
514494
// copy the unit test boilerplate
515495
.then(function() {
516496
var unittestSourceFiles =
517497
_exampleUnitTestingBoilerplateFiles
518498
.map(function(name) { return path.join(EXAMPLES_TESTING_PATH, name); });
519499
var unittestPaths = getUnitTestingPaths(EXAMPLES_PATH);
520500
return copyFiles(unittestSourceFiles, unittestPaths, destFileMode);
501+
})
502+
.catch(function(err) {
503+
gutil.log(err);
504+
throw err;
521505
});
522506
}
523507

@@ -596,11 +580,6 @@ function deleteExampleBoilerPlate() {
596580
return deleteFiles(_exampleBoilerplateFiles, examplePaths)
597581
.then(function() {
598582
return deleteFiles(_exampleDartWebBoilerPlateFiles, dartExampleWebPaths);
599-
})
600-
.then(function() {
601-
var protractorFiles = _exampleProtractorBoilerplateFiles;
602-
var e2eSpecPaths = getE2eSpecPaths(EXAMPLES_PATH);
603-
return deleteFiles(protractorFiles, e2eSpecPaths);
604583
});
605584
}
606585

@@ -820,7 +799,7 @@ gulp.task('_harp-compile', function() {
820799

821800
gulp.task('_shred-devguide-examples', ['_shred-clean-devguide', '_copy-example-boilerplate'], function() {
822801
// Split big shredding task into partials 2016-06-14
823-
var examplePaths = globby.sync(EXAMPLES_PATH+'/*/', {ignore: ['/node_modules', 'typings/', '_protractor/']});
802+
var examplePaths = globby.sync(EXAMPLES_PATH+'/*/', {ignore: ['/node_modules', 'typings/']});
824803
var promise = Promise.resolve(true);
825804
examplePaths.forEach(function (examplePath) {
826805
promise = promise.then(() => docShredder.shredSingleExampleDir(_devguideShredOptions, examplePath));
@@ -879,7 +858,6 @@ gulp.task('lint', function() {
879858
'!./public/docs/_examples/**/ts-snippets/*.ts',
880859
'!./public/docs/_examples/style-guide/ts/**/*.avoid.ts',
881860
'!./public/docs/_examples/**/node_modules/**/*',
882-
'!./public/docs/_examples/_protractor/**/*',
883861
'!./public/docs/_examples/**/typings/**/*',
884862
'!./public/docs/_examples/**/typings-ng1/**/*',
885863
'!./public/docs/_examples/**/build/**/*',
@@ -1152,7 +1130,7 @@ function getTypingsPaths(basePath) {
11521130

11531131
function getExamplePaths(basePath, includeBase) {
11541132
// includeBase defaults to false
1155-
return getPaths(basePath, _exampleConfigFilename, includeBase)
1133+
return getPaths(basePath, _exampleConfigFilename, includeBase);
11561134
}
11571135

11581136
function getDartExampleWebPaths(basePath) {
@@ -1183,6 +1161,8 @@ function getFilenames(basePath, filename, includeBase) {
11831161
// ignore (skip) the top level version.
11841162
includePatterns.push("!" + path.join(basePath, "/" + filename));
11851163
}
1164+
// ignore (skip) the files in BOILERPLATE_PATH.
1165+
includePatterns.push("!" + path.join(BOILERPLATE_PATH, "/" + filename));
11861166
var nmPattern = path.join(basePath, "**/node_modules/**");
11871167
var filenames = globby.sync(includePatterns, {ignore: [nmPattern]});
11881168
return filenames;

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"q": "^1.4.1",
7272
"tree-kill": "^1.0.0",
7373
"tslint": "^3.15.1",
74+
"typescript": "^2.0.3",
7475
"yargs": "^4.7.1"
7576
},
7677
"dependencies": {

public/docs/_examples/.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ tsconfig.json
99
tslint.json
1010
typings.json
1111
wallaby.js
12+
_boilerplate/a2docs.css
1213

13-
protractor.config.js
1414
_test-output
1515
**/ts/**/*.js
1616
**/ts-snippets/**/*.js
1717
*.d.ts
1818

1919
!**/*e2e-spec.js
2020
!systemjs.config.1.js
21+
!_boilerplate/*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "angular2-examples",
3+
"version": "1.0.0",
4+
"description": "Example package.json, only contains needed scripts for examples. See _examples/package.json for master package.json.",
5+
"scripts": {
6+
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
7+
"e2e": "tsc && concurrently \"http-server\" \"protractor protractor.config.js\"",
8+
"http-server": "tsc && http-server",
9+
"http-server:e2e": "http-server",
10+
"http-server:cli": "http-server dist/",
11+
"lite": "lite-server",
12+
"postinstall": "typings install",
13+
"test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
14+
"tsc": "tsc",
15+
"tsc:w": "tsc -w",
16+
"start:webpack": "webpack-dev-server --inline --progress --port 8080",
17+
"test:webpack": "karma start karma.webpack.conf.js",
18+
"build:webpack": "rimraf dist && webpack --config config/webpack.prod.js --bail",
19+
"build:cli": "ng build",
20+
"build:aot": "ngc -p tsconfig-aot.json && rollup -c rollup.js",
21+
"i18n": "ng-xi18n"
22+
},
23+
"keywords": [],
24+
"author": "",
25+
"license": "ISC",
26+
"dependencies": {},
27+
"devDependencies": {},
28+
"repository": {}
29+
}
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
{
22
"compilerOptions": {
3-
"target": "es6",
3+
"target": "es5",
44
"module": "commonjs",
55
"moduleResolution": "node",
66
"sourceMap": true,
77
"emitDecoratorMetadata": true,
88
"experimentalDecorators": true,
99
"removeComments": false,
1010
"noImplicitAny": true,
11-
"suppressImplicitAnyIndexErrors": true
12-
},
13-
"files": [
14-
"e2e-spec.ts"
15-
]
11+
"suppressImplicitAnyIndexErrors": true,
12+
"types": []
13+
}
1614
}

public/docs/_examples/_protractor/e2e.d.ts

-14
This file was deleted.

public/docs/_examples/_protractor/package.json

-21
This file was deleted.

public/docs/_examples/_protractor/typings.json

-8
This file was deleted.

0 commit comments

Comments
 (0)