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

Commit d1d5adc

Browse files
committed
test(e2e/dart): add support for Dart e2e testing
This task runs the *same e2e test suites as for TS*, since the example apps should behave the same in TS and Dart. For now, only - quickstart - toh (toh-5) tests are enabled. ALL Dart tests are passing!
1 parent 8b1683f commit d1d5adc

File tree

3 files changed

+39
-9
lines changed

3 files changed

+39
-9
lines changed

gulpfile.js

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,11 @@ gulp.task('run-e2e-tests', function() {
109109
// with the corresponding apps that they should run under. Then run
110110
// each app/spec collection sequentially.
111111
function findAndRunE2eTests(filter) {
112+
var lang = argv.lang || 'ts';
112113
var startTime = new Date().getTime();
113114
// create an output file with header.
114115
var outputFile = path.join(process.cwd(), 'protractor-results.txt');
115-
var header = "Protractor example results for: " + (new Date()).toLocaleString() + "\n\n";
116+
var header = "Protractor example results for " + lang + " on " + (new Date()).toLocaleString() + "\n\n";
116117
if (filter) {
117118
header += ' Filter: ' + filter.toString() + '\n\n';
118119
}
@@ -128,6 +129,10 @@ function findAndRunE2eTests(filter) {
128129
fsExtra.copySync(srcConfig, destConfig);
129130
// get all of the examples under each dir where a pcFilename is found
130131
examplePaths = getExamplePaths(specPath, true);
132+
// Filter by language
133+
examplePaths = examplePaths.filter(function (fn) {
134+
return fn.match('/'+lang+'$') != null;
135+
});
131136
if (filter) {
132137
examplePaths = examplePaths.filter(function (fn) {
133138
return fn.match(filter) != null;
@@ -142,7 +147,8 @@ function findAndRunE2eTests(filter) {
142147
var status = { passed: [], failed: [] };
143148
return exeConfigs.reduce(function (promise, combo) {
144149
return promise.then(function () {
145-
return runE2eTests(combo.examplePath, combo.protractorConfigFilename, outputFile).then(function(ok) {
150+
var runTests = lang == 'dart' ? runE2eDartTests : runE2eTsTests;
151+
return runTests(combo.examplePath, combo.protractorConfigFilename, outputFile).then(function(ok) {
146152
var arr = ok ? status.passed : status.failed;
147153
arr.push(combo.examplePath);
148154
})
@@ -158,12 +164,16 @@ function findAndRunE2eTests(filter) {
158164
// start the example in appDir; then run protractor with the specified
159165
// fileName; then shut down the example. All protractor output is appended
160166
// to the outputFile.
161-
function runE2eTests(appDir, protractorConfigFilename, outputFile ) {
167+
function runE2eTsTests(appDir, protractorConfigFilename, outputFile) {
162168
// start the app
163169
var appRunSpawnInfo = spawnExt('npm',['run','http-server:e2e', '--', '-s' ], { cwd: appDir });
164170
var tscRunSpawnInfo = spawnExt('npm',['run','tsc'], { cwd: appDir });
165171

166-
return tscRunSpawnInfo.promise.then(function(data) {
172+
return runProtractor(tscRunSpawnInfo.promise, appDir, appRunSpawnInfo, protractorConfigFilename, outputFile);
173+
}
174+
175+
function runProtractor(prepPromise, appDir, appRunSpawnInfo, protractorConfigFilename, outputFile) {
176+
return prepPromise.then(function (data) {
167177
// start protractor
168178
var pcFilename = path.resolve(protractorConfigFilename); // need to resolve because we are going to be running from a different dir
169179
var exePath = path.join(process.cwd(), "./node_modules/.bin/");
@@ -184,19 +194,39 @@ function runE2eTests(appDir, protractorConfigFilename, outputFile ) {
184194
});
185195
}
186196

197+
// start the server in appDir/build/web; then run protractor with the specified
198+
// fileName; then shut down the example. All protractor output is appended
199+
// to the outputFile.
200+
function runE2eDartTests(appDir, protractorConfigFilename, outputFile) {
201+
var deployDir = path.resolve(path.join(appDir, 'build/web'));
202+
gutil.log('AppDir for Dart e2e: ' + appDir);
203+
gutil.log('Deploying from: ' + deployDir);
204+
205+
var appRunSpawnInfo = spawnExt('npm', ['run', 'http-server:e2e', '--', deployDir, '-s'], { cwd: EXAMPLES_PATH });
206+
if (!appRunSpawnInfo.proc.pid) {
207+
gutil.log('http-server failed to launch over ' + deployDir);
208+
return false;
209+
}
210+
var pubUpgradeSpawnInfo = spawnExt('pub', ['upgrade'], { cwd: appDir });
211+
var prepPromise = pubUpgradeSpawnInfo.promise.then(function (data) {
212+
return spawnExt('pub', ['build'], { cwd: appDir }).promise;
213+
});
214+
return runProtractor(prepPromise, appDir, appRunSpawnInfo, protractorConfigFilename, outputFile);
215+
}
216+
187217
function reportStatus(status) {
188218
gutil.log('Suites passed:');
189219
status.passed.forEach(function(val) {
190220
gutil.log(' ' + val);
191221
});
192222

193-
gutil.log('Suites failed:');
194-
status.failed.forEach(function(val) {
195-
gutil.log(' ' + val);
196-
});
197-
198223
if (status.failed.length == 0) {
199224
gutil.log('All tests passed');
225+
} else {
226+
gutil.log('Suites failed:');
227+
status.failed.forEach(function (val) {
228+
gutil.log(' ' + val);
229+
});
200230
}
201231
gutil.log('Elapsed time: ' + status.elapsedTime + ' seconds');
202232
}

public/docs/_examples/quickstart/dart/example-config.json

Whitespace-only changes.

public/docs/_examples/toh-5/dart/example-config.json

Whitespace-only changes.

0 commit comments

Comments
 (0)