Files
compiler-explorer/static/tests/frontend-testing.ts
T
Mats Larsen 4f9a34c511 Also enable prettier for recursive directories in static (#3539)
* Also enable prettier for recursive directories in static

* Fix formatting

* Fixes
2022-04-24 19:11:48 +02:00

31 lines
803 B
TypeScript

import {IFrontendTesting, ITestable} from './frontend-testing.interfaces';
class FrontendTesting implements IFrontendTesting {
private testSuites: Array<ITestable> = [];
public add(test: ITestable) {
this.testSuites.push(test);
}
public getAllTestNames(): string[] {
return this.testSuites.map(val => val.description);
}
private findTest(name: string) {
for (const suite of this.testSuites) {
if (suite.description === name) {
return suite;
}
}
throw new Error(`Can't find test ${name}`);
}
public async run(testToRun: string) {
const testSuite = this.findTest(testToRun);
await testSuite.run();
}
}
window.compilerExplorerFrontendTesting = new FrontendTesting();