Skip to content

Commit

Permalink
Update usage
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Smalley <tyler@tailscale.com>
  • Loading branch information
tylersmalley committed Jun 21, 2023
1 parent 011962b commit 58ff70f
Showing 1 changed file with 19 additions and 23 deletions.
42 changes: 19 additions & 23 deletions src/test/suite/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as path from 'path';
import * as Mocha from 'mocha';
import * as glob from 'glob';
import { 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 @@ -11,28 +11,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('**/**.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);
}
});
return new Promise((c, e) => {
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);
}
});
}

0 comments on commit 58ff70f

Please sign in to comment.