[Debugger, JS] Configure timeouts for debugging
This commit is contained in:
+16
@@ -257,6 +257,22 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) : KotlinJsTestF
|
||||
): TCServiceMessagesTestExecutionSpec {
|
||||
if (debug) {
|
||||
config.singleRun = false
|
||||
|
||||
confJsWriters.add {
|
||||
//language=ES6
|
||||
it.appendln(
|
||||
"""
|
||||
if (!config.plugins) {
|
||||
config.plugins = config.plugins || [];
|
||||
config.plugins.push('karma-*'); // default
|
||||
}
|
||||
|
||||
config.plugins.push('kotlin-test-js-runner/karma-debug-framework.js');
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
config.frameworks.add("karma-kotlin-debug")
|
||||
}
|
||||
|
||||
if (config.browsers.isEmpty()) {
|
||||
|
||||
@@ -54,6 +54,7 @@ tasks {
|
||||
"karma.ts",
|
||||
"karma-kotlin-reporter.js",
|
||||
"karma-debug-runner.js",
|
||||
"karma-debug-framework.js",
|
||||
"mocha-kotlin-reporter.js",
|
||||
"package.json",
|
||||
"rollup.config.js",
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const initDebug = function (injector) {
|
||||
configureTimeouts(injector)
|
||||
};
|
||||
|
||||
function configureTimeouts(injector) {
|
||||
const webServer = injector.get('webServer');
|
||||
if (webServer) {
|
||||
// IDE posts http '/run' request to trigger tests (see intellijRunner.js).
|
||||
// If a request executes more than `httpServer.timeout`, it will be timed out.
|
||||
// Disable timeout, as by default httpServer.timeout=120 seconds, not enough for suspended execution.
|
||||
webServer.timeout = 0
|
||||
}
|
||||
const socketServer = injector.get('socketServer');
|
||||
if (socketServer) {
|
||||
// Disable socket.io heartbeat (ping) to avoid browser disconnecting when debugging tests,
|
||||
// because no ping requests are sent when test execution is suspended on a breakpoint.
|
||||
// Default values are not enough for suspended execution:
|
||||
// 'heartbeat timeout' (pingTimeout) = 60000 ms
|
||||
// 'heartbeat interval' (pingInterval) = 25000 ms
|
||||
socketServer.set('heartbeat timeout', 24 * 60 * 60 * 1000);
|
||||
socketServer.set('heartbeat interval', 24 * 60 * 60 * 1000)
|
||||
}
|
||||
}
|
||||
|
||||
initDebug.$inject = ['injector'];
|
||||
|
||||
module.exports = {
|
||||
'framework:karma-kotlin-debug': ['factory', initDebug]
|
||||
};
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import {configureBrowsers, fixMochaTimeout} from "./src/DebugConfigurator";
|
||||
import {configureBrowsers, fixBrowserActivityTimeout, fixMochaTimeout} from "./src/DebugConfigurator";
|
||||
|
||||
const karma = require('karma');
|
||||
|
||||
@@ -17,6 +17,7 @@ karmaConfig.singleRun = false;
|
||||
|
||||
configureBrowsers(karmaConfig);
|
||||
fixMochaTimeout(karmaConfig);
|
||||
fixBrowserActivityTimeout(karmaConfig);
|
||||
|
||||
const Server = karma.Server;
|
||||
const server = new Server(karmaConfig, function (exitCode) {
|
||||
|
||||
@@ -32,6 +32,13 @@ export default [
|
||||
format: 'cjs'
|
||||
}
|
||||
},
|
||||
{
|
||||
input: './karma-debug-framework.js',
|
||||
output: {
|
||||
file: 'lib/karma-debug-framework.js',
|
||||
format: 'cjs'
|
||||
}
|
||||
},
|
||||
{
|
||||
input: './karma-kotlin-reporter.js',
|
||||
external: ['path', 'util'],
|
||||
|
||||
@@ -85,4 +85,8 @@ export function fixMochaTimeout(config) {
|
||||
console.error('config.client is not an object');
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
export function fixBrowserActivityTimeout(config) {
|
||||
config.browserNoActivityTimeout = null
|
||||
}
|
||||
Reference in New Issue
Block a user