diff --git a/test/gulpfile.ts b/test/gulpfile.ts index be18c5fa..b5d68dfc 100644 --- a/test/gulpfile.ts +++ b/test/gulpfile.ts @@ -31,43 +31,31 @@ 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 fixture = `${server}_${client}`; - console.log(`Running ${apiTestGlob} with ${server} server + ${client} client`); - gulp.src(apiTestGlob) - .pipe(mocha({ - reporter: 'mocha-jenkins-reporter', - require: [`${testDir}/fixtures/${fixture}.js`] - })) - .resume() // put the stream in flowing mode - .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 runTestsWithFixture = (server, client) => () => new Promise((resolve, reject) => { + const fixture = `${server}_${client}`; + gulp.src(`${apiTestDir}/*.js`) + .pipe(mocha({ + reporter: 'mocha-jenkins-reporter', + require: [`${testDir}/fixtures/${fixture}.js`] + })) + .resume() // put the stream in flowing mode + .on('end', resolve) + .on('error', reject); +}); + +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,