/* -------------------------------------------------------------------------------------------- * Copyright (c) Vu Nguyen. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ import * as path from 'path'; import Mocha from 'mocha'; import { glob } from 'glob'; export async function run(): Promise { // Create the mocha test const mocha = new Mocha({ ui: 'tdd', color: true, }); mocha.timeout(100000); const testsRoot = __dirname; const files = await glob('**.test.js', { cwd: testsRoot }); // Add files to the test suite files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f))); // Run the mocha test return new Promise((resolve, reject) => { try { mocha.run((failures) => { if (failures > 0) { reject(new Error(`${failures} tests failed.`)); } else { resolve(); } }); } catch (mochaError) { console.error(mochaError); reject(mochaError); } }); }