| 2 | require("mocha/mocha"); |
| 3 | |
| 4 | export function run(): Promise<void> { |
| 5 | return new Promise((resolve, reject) => { |
| 6 | mocha.setup({ |
| 7 | ui: "bdd", |
| 8 | reporter: undefined, |
| 9 | color: true, |
| 10 | }); |
| 11 | |
| 12 | // bundles all files in the current directory matching `*.test` |
| 13 | const importAll = (r: __WebpackModuleApi.RequireContext) => |
| 14 | r.keys().forEach(r); |
| 15 | |
| 16 | importAll(require.context("..", true, /\.test$/)); |
| 17 | |
| 18 | try { |
| 19 | // Run the mocha test |
| 20 | // You can find the output in Debug Console tab. |
| 21 | mocha.run((failures) => { |
| 22 | if (failures > 0) { |
| 23 | reject(new Error(`${failures} tests failed.`)); |
| 24 | } else { |
| 25 | resolve(); |
| 26 | } |
| 27 | }); |
| 28 | } catch (err) { |
| 29 | console.error(err); |
| 30 | reject(err); |
| 31 | } |
| 32 | }); |
| 33 | } |