mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 04:14:21 +08:00
chore(e2e): log an error if the test doesn't exist, add concurrency arg
- If the e2e test doesn’t exist then throw an error - Don’t log anything if no tests are being built - Add concurrency arg to change the number of tests being ran at once
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
|
import { accessSync, readFileSync, writeFileSync } from 'fs';
|
||||||
import { dirname, join, relative } from 'path';
|
import { dirname, join, relative } from 'path';
|
||||||
import { readFileSync, writeFileSync } from 'fs';
|
|
||||||
|
|
||||||
import * as glob from 'glob';
|
import * as glob from 'glob';
|
||||||
import { task } from 'gulp';
|
import { task } from 'gulp';
|
||||||
@ -25,11 +25,12 @@ task('e2e.prepareSass', (done: Function) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
task('e2e.prod', ['e2e.prepare'], (done: Function) => {
|
task('e2e.prod', ['e2e.prepare'], (done: Function) => {
|
||||||
|
|
||||||
// okay, first find out all of the e2e tests to run by finding all of the 'main.ts' files
|
// okay, first find out all of the e2e tests to run by finding all of the 'main.ts' files
|
||||||
filterE2eTestfiles().then((filePaths: string[]) => {
|
filterE2eTestfiles().then((filePaths: string[]) => {
|
||||||
console.log(`Compiling ${filePaths.length} E2E tests ...`);
|
if (filePaths && filePaths.length > 0) {
|
||||||
return buildTests(filePaths);
|
console.log(`Compiling ${filePaths.length} E2E tests ...`);
|
||||||
|
return buildTests(filePaths);
|
||||||
|
}
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
done();
|
done();
|
||||||
}).catch((err: Error) => {
|
}).catch((err: Error) => {
|
||||||
@ -38,6 +39,17 @@ task('e2e.prod', ['e2e.prepare'], (done: Function) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function e2eComponentExists(folderInfo: any): boolean {
|
||||||
|
let componentPath = `${SRC_COMPONENTS_ROOT}/${folderInfo.componentName}/test/${folderInfo.componentTest}/app`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
accessSync(componentPath);
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function filterE2eTestfiles() {
|
function filterE2eTestfiles() {
|
||||||
return getE2eTestFiles().then((filePaths: string[]) => {
|
return getE2eTestFiles().then((filePaths: string[]) => {
|
||||||
const entryPoints = filePaths.map(filePath => {
|
const entryPoints = filePaths.map(filePath => {
|
||||||
@ -48,8 +60,11 @@ function filterE2eTestfiles() {
|
|||||||
}).then((entryPoints: string[]) => {
|
}).then((entryPoints: string[]) => {
|
||||||
const folderInfo = getFolderInfo();
|
const folderInfo = getFolderInfo();
|
||||||
if (folderInfo && folderInfo.componentName && folderInfo.componentTest) {
|
if (folderInfo && folderInfo.componentName && folderInfo.componentTest) {
|
||||||
|
if (!e2eComponentExists(folderInfo)) {
|
||||||
|
console.log(`Can't find E2E test "${folderInfo.componentName}/test/${folderInfo.componentTest}". Make sure that the test exists and you are passing the correct folder.`);
|
||||||
|
}
|
||||||
const filtered = entryPoints.filter(entryPoint => {
|
const filtered = entryPoints.filter(entryPoint => {
|
||||||
return entryPoint.indexOf(folderInfo.componentName) >= 0 && entryPoint.indexOf(folderInfo.componentTest) >= 0;
|
return entryPoint.indexOf(`${folderInfo.componentName}/test/${folderInfo.componentTest}`) >= 0;
|
||||||
});
|
});
|
||||||
return filtered;
|
return filtered;
|
||||||
}
|
}
|
||||||
@ -74,7 +89,13 @@ function buildTests(filePaths: string[]) {
|
|||||||
const functions = filePaths.map(filePath => () => {
|
const functions = filePaths.map(filePath => () => {
|
||||||
return buildTest(filePath);
|
return buildTest(filePath);
|
||||||
});
|
});
|
||||||
return pAll(functions, {concurrency: 8}).then(() => {
|
|
||||||
|
// Run 2 tests at a time unless the `concurrency` arg is passed
|
||||||
|
let concurrentNumber = 2;
|
||||||
|
if (argv.concurrency) {
|
||||||
|
concurrentNumber = argv.concurrency;
|
||||||
|
}
|
||||||
|
return pAll(functions, {concurrency: concurrentNumber}).then(() => {
|
||||||
// copy over all of the protractor tests to the correct location now
|
// copy over all of the protractor tests to the correct location now
|
||||||
return copyProtractorTestContent(filePaths);
|
return copyProtractorTestContent(filePaths);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user