diff --git a/src/test/integration/index.ts b/src/test/integration/index.ts index 52ed124ae..47430fc61 100644 --- a/src/test/integration/index.ts +++ b/src/test/integration/index.ts @@ -1,8 +1,8 @@ -import path from 'path'; +import { glob } from 'glob'; import Mocha from 'mocha'; -import glob from 'glob'; +import path from 'path'; -export function run(): Promise { +export async function run(): Promise { // Create the mocha test const mocha = new Mocha({ ui: 'tdd', @@ -12,28 +12,22 @@ 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); - } + try { + const files = await glob('./**/**.test.js', { cwd: testsRoot }); - // Add files to the test suite - files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); + 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((resolve, reject) => { + mocha.run(failures => { + if (failures > 0) { + reject(new Error(`${failures} tests failed.`)); + } else { + resolve(); + } + }); }); - }); + } catch (err) { + console.error(err); + throw err; // Rethrow the error for the caller to handle + } }