Simplify test gulpfile and improve test order visibility

This commit is contained in:
murgatroid99 2019-11-14 16:39:11 -08:00
parent 0c61981ffc
commit eaae8fb3b6
1 changed files with 25 additions and 37 deletions

View File

@ -31,18 +31,9 @@ const install = () => {
const cleanAll = () => Promise.resolve();
const test = () => {
// run mocha tests matching a glob with a pre-required fixture,
// returning the associated gulp stream
if (!semver.satisfies(process.version, '>=10.10.0')) {
console.log(`Skipping cross-implementation tests for Node ${process.version}`);
return Promise.resolve();
}
const apiTestGlob = `${apiTestDir}/*.js`;
const runTestsWithFixture = (server, client) => new Promise((resolve, reject) => {
const runTestsWithFixture = (server, client) => () => new Promise((resolve, reject) => {
const fixture = `${server}_${client}`;
console.log(`Running ${apiTestGlob} with ${server} server + ${client} client`);
gulp.src(apiTestGlob)
gulp.src(`${apiTestDir}/*.js`)
.pipe(mocha({
reporter: 'mocha-jenkins-reporter',
require: [`${testDir}/fixtures/${fixture}.js`]
@ -51,23 +42,20 @@ const test = () => {
.on('end', resolve)
.on('error', reject);
});
var runTestsArgPairs;
if (semver.satisfies(process.version, '^8.13.0 || >=10.10.0')) {
runTestsArgPairs = [
['native', 'native'],
['native', 'js'],
['js', 'native'],
['js', 'js']
];
} else {
runTestsArgPairs = [
['native', 'native']
];
}
return runTestsArgPairs.reduce((previousPromise, argPair) => {
return previousPromise.then(runTestsWithFixture.bind(null, argPair[0], argPair[1]));
}, Promise.resolve());
};
const testNativeClientNativeServer = runTestsWithFixture('native', 'native');
const testJsClientNativeServer = runTestsWithFixture('native', 'js');
const testNativeClientJsServer = runTestsWithFixture('js', 'native');
const testJsClientJsServer = runTestsWithFixture('js', 'js');
const test = semver.satisfies(process.version, '^8.13.0 || >=10.10.0') ?
gulp.series(
testNativeClientNativeServer,
testJsClientNativeServer,
testNativeClientJsServer,
testJsClientJsServer
) :
testNativeClientNativeServer;
export {
install,