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

Commit 6751f77

Browse files
chalinwardbell
authored andcommitted
test(e2e/dart): add support for Dart e2e testing
closes #1369 Add `--lang` option whose values are any combo of `(ts|js|dart)` default is `(ts|js)` `--lang=all` runs all language tests;
1 parent 5940799 commit 6751f77

File tree

3 files changed

+41
-9
lines changed

3 files changed

+41
-9
lines changed

gulpfile.js

+41-9
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,12 @@ 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|js)').toLowerCase();
113+
if (lang === 'all') { lang = '(ts|js|dart)'; }
112114
var startTime = new Date().getTime();
113115
// create an output file with header.
114116
var outputFile = path.join(process.cwd(), 'protractor-results.txt');
115-
var header = "Protractor example results for: " + (new Date()).toLocaleString() + "\n\n";
117+
var header = "Protractor example results for " + lang + " on " + (new Date()).toLocaleString() + "\n\n";
116118
if (filter) {
117119
header += ' Filter: ' + filter.toString() + '\n\n';
118120
}
@@ -128,6 +130,10 @@ function findAndRunE2eTests(filter) {
128130
fsExtra.copySync(srcConfig, destConfig);
129131
// get all of the examples under each dir where a pcFilename is found
130132
examplePaths = getExamplePaths(specPath, true);
133+
// Filter by language
134+
examplePaths = examplePaths.filter(function (fn) {
135+
return fn.match('/'+lang+'$') != null;
136+
});
131137
if (filter) {
132138
examplePaths = examplePaths.filter(function (fn) {
133139
return fn.match(filter) != null;
@@ -142,7 +148,9 @@ function findAndRunE2eTests(filter) {
142148
var status = { passed: [], failed: [] };
143149
return exeConfigs.reduce(function (promise, combo) {
144150
return promise.then(function () {
145-
return runE2eTests(combo.examplePath, combo.protractorConfigFilename, outputFile).then(function(ok) {
151+
var isDart = combo.examplePath.indexOf('/dart') > -1;
152+
var runTests = isDart ? runE2eDartTests : runE2eTsTests;
153+
return runTests(combo.examplePath, combo.protractorConfigFilename, outputFile).then(function(ok) {
146154
var arr = ok ? status.passed : status.failed;
147155
arr.push(combo.examplePath);
148156
})
@@ -158,12 +166,16 @@ function findAndRunE2eTests(filter) {
158166
// start the example in appDir; then run protractor with the specified
159167
// fileName; then shut down the example. All protractor output is appended
160168
// to the outputFile.
161-
function runE2eTests(appDir, protractorConfigFilename, outputFile ) {
169+
function runE2eTsTests(appDir, protractorConfigFilename, outputFile) {
162170
// start the app
163171
var appRunSpawnInfo = spawnExt('npm',['run','http-server:e2e', '--', '-s' ], { cwd: appDir });
164172
var tscRunSpawnInfo = spawnExt('npm',['run','tsc'], { cwd: appDir });
165173

166-
return tscRunSpawnInfo.promise.then(function(data) {
174+
return runProtractor(tscRunSpawnInfo.promise, appDir, appRunSpawnInfo, protractorConfigFilename, outputFile);
175+
}
176+
177+
function runProtractor(prepPromise, appDir, appRunSpawnInfo, protractorConfigFilename, outputFile) {
178+
return prepPromise.then(function (data) {
167179
// start protractor
168180
var pcFilename = path.resolve(protractorConfigFilename); // need to resolve because we are going to be running from a different dir
169181
var exePath = path.join(process.cwd(), "./node_modules/.bin/");
@@ -184,19 +196,39 @@ function runE2eTests(appDir, protractorConfigFilename, outputFile ) {
184196
});
185197
}
186198

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

193-
gutil.log('Suites failed:');
194-
status.failed.forEach(function(val) {
195-
gutil.log(' ' + val);
196-
});
197-
198225
if (status.failed.length == 0) {
199226
gutil.log('All tests passed');
227+
} else {
228+
gutil.log('Suites failed:');
229+
status.failed.forEach(function (val) {
230+
gutil.log(' ' + val);
231+
});
200232
}
201233
gutil.log('Elapsed time: ' + status.elapsedTime + ' seconds');
202234
}

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)