[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
+19 -22
View File
@@ -5,28 +5,25 @@
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(),
(exitCode) => {
throw new Error(`Exit with ${exitCode}`)
}
);
const untypedArgs = parser.parse(window.__karma__.config.args);
const adapterTransformer: (current: KotlinTestRunner) => KotlinTestRunner = current =>
runWithFilteringAndConsoleAdapters(current, untypedArgs);
window.kotlinTest = {
adapterTransformer: adapterTransformer
}
if (kotlin_test) {
const parser = new CliArgsParser(
getDefaultCliDescription(),
(exitCode) => {
throw new Error(`Exit with ${exitCode}`)
}
);
const untypedArgs = parser.parse(window.__karma__.config.args);
const initialAdapter = kotlin_test.kotlin.test.detectAdapter_8be2vx$();
kotlin_test.setAdapter(runWithFilteringAndConsoleAdapters(initialAdapter, untypedArgs));
const resultFun = window.__karma__.result;
window.__karma__.result = function (result) {
console.log(`--END_KOTLIN_TEST--\n${JSON.stringify(result)}`);
resultFun(result)
};
}
const resultFun = window.__karma__.result;
window.__karma__.result = function (result) {
console.log(`--END_KOTLIN_TEST--\n${JSON.stringify(result)}`);
resultFun(result)
};