Skip to content

Commit 017af7b

Browse files
committed
get rid of mocha-simple
1 parent 795ce9f commit 017af7b

4 files changed

Lines changed: 478 additions & 646 deletions

File tree

Gulpfile.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const gulp = require('gulp');
22
const gulpStep = require('gulp-step');
33
const data = require('gulp-data');
44
const less = require('gulp-less');
5-
const mocha = require('gulp-mocha-simple');
65
const mustache = require('gulp-mustache');
76
const rename = require('gulp-rename');
87
const uglify = require('gulp-uglify');
@@ -28,6 +27,7 @@ const promisifyStream = require('./gulp/helpers/promisify-stream')
2827
const testFunctional = require('./gulp/helpers/test-functional');
2928
const moduleExportsTransform = require('./gulp/helpers/module-exports-transform');
3029
const createPackageFilesForTests = require('./gulp/helpers/create-package-files-for-tests');
30+
const { runCommands } = require('./gulp/helpers/run-shell-commands');
3131

3232
const {
3333
TESTS_GLOB,
@@ -254,7 +254,7 @@ gulp.step('clean-functional-tests', async () => {
254254

255255
gulp.step('prepare-tests', gulp.registry().get(SKIP_BUILD ? 'lint' : 'build'));
256256

257-
gulp.step('test-server-run', () => {
257+
gulp.step('test-server-run', async () => {
258258
const chai = require('chai');
259259

260260
chai.use(require('chai-string'));
@@ -264,11 +264,11 @@ gulp.step('test-server-run', () => {
264264
const domains = exitDomains();
265265

266266
try {
267-
return gulp
268-
.src('test/server/*-test.js', { read: false })
269-
.pipe(mocha({
270-
timeout: getTimeout(4_000),
271-
}));
267+
const timeout = getTimeout(4_000) === Infinity ? 0 : getTimeout(4_000);
268+
269+
await runCommands([
270+
`npx --no-install mocha --full-trace --timeout ${timeout} "test/server/*-test.js"`,
271+
]);
272272
}
273273
finally {
274274
enterDomains(domains);

gulp/helpers/run-shell-commands.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const childProcess = require('child_process');
2+
3+
async function runCommands (commands) {
4+
for (const command of commands) {
5+
const commandExitCode = await new Promise((resolve, reject) => {
6+
const child = childProcess.spawn(command, { shell: true, stdio: 'inherit' });
7+
8+
child.on('error', reject);
9+
child.on('close', code => {
10+
resolve(code ?? 1);
11+
});
12+
});
13+
14+
if (commandExitCode !== 0)
15+
throw new Error(`Command "${command}" exited with code ${commandExitCode}`);
16+
}
17+
}
18+
19+
exports.runCommands = runCommands;

0 commit comments

Comments
 (0)