1 import * as path from 'path';
5 readonly promise: Promise<void>;
7 constructor(name: string, promise: Promise<void>) {
9 this.promise = promise;
20 public addTest(name: string, f: () => Promise<void>): void {
21 const test = new Test(name, f());
22 this.tests.push(test);
25 public async run(): Promise<void> {
27 for (const test of this.tests) {
30 ok(` ✔ ${test.name}`);
32 error(` ✖︎ ${test.name}\n ${e.stack}`);
37 const plural = failed > 1 ? "s" : "";
38 throw new Error(`${failed} failed test${plural}`);
43 export class Context {
44 public async suite(name: string, f: (ctx: Suite) => void): Promise<void> {
45 const ctx = new Suite();
52 error(`✖︎ ${name}\n ${e.stack}`);
58 export async function run(): Promise<void> {
59 const context = new Context();
60 const testFiles = ["launch_config.test.js", "runnable_env.test.js"];
61 for (const testFile of testFiles) {
63 const testModule = require(path.resolve(__dirname, testFile));
64 await testModule.getTests(context);
72 function ok(message: string): void {
73 // eslint-disable-next-line no-console
74 console.log(`\x1b[32m${message}\x1b[0m`);
77 function error(message: string): void {
78 // eslint-disable-next-line no-console
79 console.error(`\x1b[31m${message}\x1b[0m`);