Skip to content

Commit 8ab8245

Browse files
author
Vladimir Makayev
committed
Implement async/await for e2e tests
1 parent dc3d841 commit 8ab8245

File tree

13 files changed

+89
-23
lines changed

13 files changed

+89
-23
lines changed

gulpfile.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ gulp.task('build.dev.watch', (done: any) =>
3131
// --------------
3232
// Build e2e.
3333
gulp.task('build.e2e', (done: any) =>
34-
runSequence('clean.dev',
34+
runSequence('clean.e2e',
3535
'tslint',
36-
'build.assets.dev',
3736
'build.js.e2e',
38-
'build.index.dev',
3937
done));
4038

4139
// --------------
@@ -110,8 +108,12 @@ gulp.task('serve.dev', (done: any) =>
110108
// --------------
111109
// Serve e2e
112110
gulp.task('serve.e2e', (done: any) =>
113-
runSequence('build.e2e',
111+
runSequence(
112+
'tslint',
113+
'build.dev',
114+
'build.js.e2e',
114115
'server.start',
116+
'watch.dev',
115117
'watch.e2e',
116118
done));
117119

protractor.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const config = {
22
baseUrl: 'http://localhost:5555/',
33

44
specs: [
5-
'./dist/dev/**/*.e2e-spec.js'
5+
'./dist/e2e/**/*.e2e-spec.js'
66
],
77

88
exclude: [],

src/client/app/about/about.component.e2e-spec.ts renamed to src/e2e/specs/about.component.e2e-spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
describe('About', () => {
22

3-
beforeEach( () => {
4-
browser.get('/about');
3+
beforeEach(async () => {
4+
return await browser.get('/about');
55
});
66

77
it('should have correct feature heading', () => {

src/client/app/app.component.e2e-spec.ts renamed to src/e2e/specs/app.component.e2e-spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
describe('App', () => {
22

3-
beforeEach( () => {
4-
browser.get('/');
3+
beforeEach(async () => {
4+
return await browser.get('/');
55
});
66

77
it('should have a title', () => {

src/client/app/home/home.component.e2e-spec.ts renamed to src/e2e/specs/home.component.e2e-spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
describe('Home', () => {
22

3-
beforeEach( () => {
4-
browser.get('/');
3+
beforeEach(async () => {
4+
return await browser.get('/');
55
});
66

77
it('should have an input', () => {

src/e2e/tsconfig.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2015",
4+
"module": "commonjs",
5+
"declaration": false,
6+
"removeComments": true,
7+
"noLib": false,
8+
"emitDecoratorMetadata": true,
9+
"experimentalDecorators": true,
10+
"sourceMap": true,
11+
"pretty": true,
12+
"allowUnreachableCode": false,
13+
"allowUnusedLabels": false,
14+
"noImplicitAny": false,
15+
"noImplicitReturns": true,
16+
"noImplicitUseStrict": false,
17+
"noFallthroughCasesInSwitch": true,
18+
"typeRoots": [
19+
"../../node_modules/@types",
20+
"../../node_modules"
21+
],
22+
"types": [
23+
"express",
24+
"jasmine",
25+
"node",
26+
"protractor",
27+
"systemjs"
28+
]
29+
},
30+
"exclude": [
31+
"desktop",
32+
"nativescript",
33+
"node_modules",
34+
"dist",
35+
"src"
36+
],
37+
"compileOnSave": false
38+
}

tools/config/seed.config.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ export class SeedConfig {
152152
*/
153153
APP_SRC = `src/${this.APP_CLIENT}`;
154154

155+
/**
156+
* The name of the TypeScript project file
157+
* @type {string}
158+
*/
159+
APP_PROJECTNAME = 'tsconfig.json';
160+
155161
/**
156162
* The folder of the applications asset files.
157163
* @type {string}
@@ -164,6 +170,11 @@ export class SeedConfig {
164170
*/
165171
CSS_SRC = `${this.APP_SRC}/css`;
166172

173+
/**
174+
* The folder of the e2e specs and framework
175+
*/
176+
E2E_SRC = 'src/e2e';
177+
167178
/**
168179
* The folder of the applications scss files.
169180
* @type {string}
@@ -205,6 +216,12 @@ export class SeedConfig {
205216
*/
206217
PROD_DEST = `${this.DIST_DIR}/prod`;
207218

219+
/**
220+
* The folder for the built files of the e2e-specs.
221+
* @type {string}
222+
*/
223+
E2E_DEST = `${this.DIST_DIR}/e2e`;
224+
208225
/**
209226
* The folder for temporary files.
210227
* @type {string}

tools/tasks/seed/build.js.e2e.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ const jsonSystemConfig = JSON.stringify(Config.SYSTEM_CONFIG_DEV);
1313
* for the e2e environment.
1414
*/
1515
export = () => {
16-
let tsProject = makeTsProject();
16+
let tsProject = makeTsProject({ 'target': 'es2015' }, Config.E2E_SRC);
1717
let src = [
1818
Config.TOOLS_DIR + '/manual_typings/**/*.d.ts',
19-
join(Config.APP_SRC, '**/*.ts'),
20-
'!' + join(Config.APP_SRC, '**/*.spec.ts'),
21-
'!' + join(Config.APP_SRC, `**/${Config.NG_FACTORY_FILE}.ts`)
19+
join(Config.E2E_SRC, '**/*.ts')
2220
];
2321
let result = gulp.src(src)
2422
.pipe(plugins.plumber())
@@ -30,5 +28,5 @@ export = () => {
3028
.pipe(plugins.template(Object.assign(templateLocals(), {
3129
SYSTEM_CONFIG_DEV: jsonSystemConfig
3230
})))
33-
.pipe(gulp.dest(Config.APP_DEST));
31+
.pipe(gulp.dest(Config.E2E_DEST));
3432
};

tools/tasks/seed/clean.e2e.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Config from '../../config';
2+
import { clean } from '../../utils';
3+
4+
/**
5+
* Executes the build process, cleaning all files within the `/dist/dev` directory.
6+
*/
7+
export = clean(Config.E2E_DEST);

tools/tasks/seed/tslint.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export = () => {
1313
let src = [
1414
join(Config.APP_SRC, '**/*.ts'),
1515
'!' + join(Config.APP_SRC, '**/*.d.ts'),
16+
join(Config.E2E_SRC, '**/*.ts'),
17+
'!' + join(Config.E2E_SRC, '**/*.d.ts'),
1618
join(Config.TOOLS_DIR, '**/*.ts'),
1719
'!' + join(Config.TOOLS_DIR, '**/*.d.ts')
1820
];

tools/tasks/seed/watch.e2e.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { watch } from '../../utils';
2+
import Config from '../../config';
23

34
/**
45
* Executes the build process, watching for file changes and rebuilding the e2e environment.
56
*/
6-
export = watch('build.e2e');
7+
export = watch('build.e2e', Config.E2E_SRC);

tools/utils/seed/tsproject.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as gulpLoadPlugins from 'gulp-load-plugins';
22
import { join } from 'path';
3+
import ts = require('gulp-typescript/release/main');
34

45
import Config from '../../config';
56

@@ -11,14 +12,14 @@ let tsProjects: any = {};
1112
* Creates a TypeScript project with the given options using the gulp typescript plugin.
1213
* @param {Object} options - The additional options for the project configuration.
1314
*/
14-
export function makeTsProject(options: Object = {}, pathToTsConfig: string = Config.APP_SRC) {
15+
export function makeTsProject(options: ts.Settings = {}, pathToTsConfig: string = Config.APP_SRC, projectName = Config.APP_PROJECTNAME) {
1516
let optionsHash = JSON.stringify(options);
1617
if (!tsProjects[optionsHash]) {
1718
let config = Object.assign({
1819
typescript: require('typescript')
1920
}, options);
2021
tsProjects[optionsHash] =
21-
plugins.typescript.createProject(join(pathToTsConfig, 'tsconfig.json'), config);
22+
plugins.typescript.createProject(join(pathToTsConfig, projectName), config);
2223
}
2324
return tsProjects[optionsHash];
2425
}

tools/utils/seed/watch.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ const plugins = <any>gulpLoadPlugins();
1212
* Watches the task with the given taskname.
1313
* @param {string} taskname - The name of the task.
1414
*/
15-
export function watch(taskname: string) {
15+
export function watch(taskname: string, root: string = Config.APP_SRC) {
1616
return function () {
17-
let paths:string[]=[
18-
join(Config.APP_SRC,'**')
19-
].concat(Config.TEMP_FILES.map((p) => { return '!'+p; }));
17+
let paths: string[] = [
18+
join(root, '**')
19+
].concat(Config.TEMP_FILES.map((p) => { return '!' + p; }));
2020

2121
plugins.watch(paths, (e: any) => {
2222
changeFileManager.addFile(e.path);

0 commit comments

Comments
 (0)