diff --git a/src/test/suite/index.ts b/src/test/suite/index.ts index 8ced9b1..d760d42 100644 --- a/src/test/suite/index.ts +++ b/src/test/suite/index.ts @@ -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 { +export async function run(): Promise { // Create the mocha test const mocha = new Mocha({ ui: 'tdd', @@ -11,28 +11,24 @@ export function run(): Promise { 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); + } }); }