[JS] Implement strategy with adapterTransformer on global object to mutate adapter of kotlin-test

This commit is contained in:
Ilya Goncharov
2021-11-08 20:47:28 +03:00
committed by Space
parent 272081d8cf
commit 7aef45d5cf
4 changed files with 62 additions and 45 deletions
+10 -13
View File
@@ -1,19 +1,16 @@
import {CliArgsParser, getDefaultCliDescription} from "./src/CliArgsParser";
import {runWithFilteringAndConsoleAdapters} from "./src/Adapter";
import {KotlinTestRunner} from "./src/KotlinTestRunner";
let kotlin_test
try {
kotlin_test = require('kotlin-test');
} catch {
}
const parser = new CliArgsParser(
getDefaultCliDescription(),
process.exit
);
const untypedArgs = parser.parse(process.argv);
if (kotlin_test) {
const parser = new CliArgsParser(
getDefaultCliDescription(),
process.exit
);
const untypedArgs = parser.parse(process.argv);
const adapterTransformer: (current: KotlinTestRunner) => KotlinTestRunner = current =>
runWithFilteringAndConsoleAdapters(current, untypedArgs);
const initialAdapter = kotlin_test.kotlin.test.detectAdapter_8be2vx$();
kotlin_test.setAdapter(runWithFilteringAndConsoleAdapters(initialAdapter, untypedArgs));
(globalThis as any).kotlinTest = {
adapterTransformer: adapterTransformer
}