[Gradle, JS] Improvements of kotlin test adapters

- divide adapter.js into different files, which frameworks could load separately
- possibility to inject something to kotlin-test adapter by user

^KT-54418 fixed
This commit is contained in:
Ilya Goncharov
2022-10-12 14:14:50 +00:00
committed by Space Team
parent d423782fac
commit b01411544a
4 changed files with 19 additions and 55 deletions
+10 -2
View File
@@ -13,10 +13,18 @@ const parser = new CliArgsParser(
throw new Error(`Exit with ${exitCode}`)
}
);
const untypedArgs = parser.parse(window.__karma__.config.args);
const adapterTransformer: (current: KotlinTestRunner) => KotlinTestRunner = current =>
runWithFilteringAndConsoleAdapters(current, untypedArgs);
let adapterTransformer: (current: KotlinTestRunner) => KotlinTestRunner
if (window.kotlinTest) {
const currentAdapterTransformer = window.kotlinTest.adapterTransformer;
adapterTransformer = current =>
runWithFilteringAndConsoleAdapters(currentAdapterTransformer(current), untypedArgs);
} else {
adapterTransformer = current =>
runWithFilteringAndConsoleAdapters(current, untypedArgs);
}
window.kotlinTest = {
adapterTransformer: adapterTransformer
@@ -36,8 +36,6 @@ export function runWithTeamCityConsoleAdapter(
runner.suite(name, isIgnored, fn)
},
test: function (name: string, isIgnored: boolean, fn: () => void) {
let revertLogMethods: CallableFunction[] = [];
runner.test(name, isIgnored, () => {
const log = (type: LogType) => function (message?: any, ...optionalParams: any[]) {
let messageType: 'testStdOut' | 'testStdErr'
@@ -62,7 +60,7 @@ export function runWithTeamCityConsoleAdapter(
[method: string]: (message?: any, ...optionalParams: any[]) => void
};
revertLogMethods = logTypes
const revertLogMethods = logTypes
.map(method => {
const realMethod = globalConsole[method];
globalConsole[method] = log(method);