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 cleanAll = () => Promise.resolve();
const test = () => { const runTestsWithFixture = (server, client) => () => new Promise((resolve, reject) => {
// 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 fixture = `${server}_${client}`; const fixture = `${server}_${client}`;
console.log(`Running ${apiTestGlob} with ${server} server + ${client} client`); gulp.src(`${apiTestDir}/*.js`)
gulp.src(apiTestGlob)
.pipe(mocha({ .pipe(mocha({
reporter: 'mocha-jenkins-reporter', reporter: 'mocha-jenkins-reporter',
require: [`${testDir}/fixtures/${fixture}.js`] require: [`${testDir}/fixtures/${fixture}.js`]
@ -50,24 +41,21 @@ const test = () => {
.resume() // put the stream in flowing mode .resume() // put the stream in flowing mode
.on('end', resolve) .on('end', resolve)
.on('error', reject); .on('error', reject);
}); });
var runTestsArgPairs;
if (semver.satisfies(process.version, '^8.13.0 || >=10.10.0')) { const testNativeClientNativeServer = runTestsWithFixture('native', 'native');
runTestsArgPairs = [ const testJsClientNativeServer = runTestsWithFixture('native', 'js');
['native', 'native'], const testNativeClientJsServer = runTestsWithFixture('js', 'native');
['native', 'js'], const testJsClientJsServer = runTestsWithFixture('js', 'js');
['js', 'native'],
['js', 'js'] const test = semver.satisfies(process.version, '^8.13.0 || >=10.10.0') ?
]; gulp.series(
} else { testNativeClientNativeServer,
runTestsArgPairs = [ testJsClientNativeServer,
['native', 'native'] testNativeClientJsServer,
]; testJsClientJsServer
} ) :
return runTestsArgPairs.reduce((previousPromise, argPair) => { testNativeClientNativeServer;
return previousPromise.then(runTestsWithFixture.bind(null, argPair[0], argPair[1]));
}, Promise.resolve());
};
export { export {
install, install,