Files
kotlin-fork/libraries/tools/kotlin-test-js-runner/karma.ts
T
2021-10-15 11:37:42 +03:00

32 lines
1.0 KiB
TypeScript
Executable File

/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
import {CliArgsParser, getDefaultCliDescription} from "./src/CliArgsParser";
import {runWithFilteringAndConsoleAdapters} from "./src/Adapter";
let kotlin_test
try {
kotlin_test = require('kotlin-test');
} catch {
}
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)
};
}