Skip to content

Commit

Permalink
fix: adjust test runner that was not compiling with modern glob
Browse files Browse the repository at this point in the history
  • Loading branch information
ssimek committed Jan 16, 2025
1 parent a2a8a6f commit d60436c
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions test/suite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as path from 'path';
import * as Mocha from 'mocha';
import * as glob from 'glob';

export function run(): Promise<void> {
export async function run(): Promise<void> {
// Create the mocha test
const mocha = new Mocha({
ui: 'tdd'
Expand All @@ -12,28 +12,24 @@ export function run(): Promise<void> {

const testsRoot = path.resolve(__dirname, '..');

return new Promise((c, e) => {
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
if (err) {
return e(err);
}
const files = await glob.glob('**/**.test.js', { cwd: testsRoot });

// Add files to the test suite
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));
// Add files to the test suite
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));

try {
// Run the mocha test
mocha.run((failures) => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
} else {
c();
}
});
} catch (err) {
console.error(err);
e(err);
}
try {
// Run the mocha test
await new Promise<void>((c, e) => {
mocha.run((failures) => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
} else {
c();
}
});
});
});
} catch (err) {
console.error(err);
throw err;
}
}

0 comments on commit d60436c

Please sign in to comment.