diff --git a/src/browser/commands/switchToRepl.ts b/src/browser/commands/switchToRepl.ts index 87d3c841e..f4f119940 100644 --- a/src/browser/commands/switchToRepl.ts +++ b/src/browser/commands/switchToRepl.ts @@ -54,7 +54,7 @@ export = async (browser: Browser): Promise => { return; } - logger.log(chalk.yellow("You have entered REPL mode via terminal")); + logger.log(chalk.yellow("You have entered to REPL mode via terminal (test execution timeout is disabled).")); const currCwd = process.cwd(); const testCwd = path.dirname(session.executionContext.ctx.currentTest.file!); diff --git a/src/test-reader/build-instructions.js b/src/test-reader/build-instructions.js index 02c8966a0..e81a728ed 100644 --- a/src/test-reader/build-instructions.js +++ b/src/test-reader/build-instructions.js @@ -1,6 +1,7 @@ const _ = require("lodash"); const validators = require("../validators"); const env = require("../utils/env"); +const RuntimeConfig = require("../config/runtime-config"); class InstructionsList { #commonInstructions; @@ -51,7 +52,9 @@ function extendWithBrowserVersion({ treeBuilder, config }) { function extendWithTimeout({ treeBuilder, config }) { const { testTimeout } = config; - if (!_.isNumber(testTimeout)) { + const { replMode } = RuntimeConfig.getInstance(); + + if (!_.isNumber(testTimeout) || replMode?.enabled) { return; } diff --git a/src/test-reader/controllers/config-controller.ts b/src/test-reader/controllers/config-controller.ts index f66a7dd4f..5b52d9efe 100644 --- a/src/test-reader/controllers/config-controller.ts +++ b/src/test-reader/controllers/config-controller.ts @@ -1,5 +1,6 @@ import { TestReaderEvents as ReadEvents } from "../../events"; import { EventEmitter } from "events"; +import RuntimeConfig from "../../config/runtime-config"; type TreeBuilder = { addTrap: (trap: (obj: { timeout: number }) => void) => void; @@ -17,6 +18,12 @@ export class ConfigController { } testTimeout(timeout: number): this { + const { replMode } = RuntimeConfig.getInstance(); + + if (replMode?.enabled) { + return this; + } + this.#eventBus.emit(ReadEvents.NEW_BUILD_INSTRUCTION, ({ treeBuilder }: { treeBuilder: TreeBuilder }) => { treeBuilder.addTrap(obj => (obj.timeout = timeout)); }); diff --git a/test/src/browser/commands/switchToRepl.ts b/test/src/browser/commands/switchToRepl.ts index 393e7f73d..d6f8206a0 100644 --- a/test/src/browser/commands/switchToRepl.ts +++ b/test/src/browser/commands/switchToRepl.ts @@ -84,7 +84,9 @@ describe('"switchToRepl" command', () => { await switchToRepl_({ session }); assert.callOrder( - (logger.log as SinonStub).withArgs(chalk.yellow("You have entered REPL mode via terminal")), + (logger.log as SinonStub).withArgs( + chalk.yellow("You have entered to REPL mode via terminal (test execution timeout is disabled)."), + ), repl.start as SinonStub, ); }); diff --git a/test/src/test-reader/build-instructions.js b/test/src/test-reader/build-instructions.js index 8abe168eb..c145a2ef6 100644 --- a/test/src/test-reader/build-instructions.js +++ b/test/src/test-reader/build-instructions.js @@ -5,6 +5,7 @@ const { InstructionsList, Instructions } = require("src/test-reader/build-instru const { TreeBuilder } = require("src/test-reader/tree-builder"); const validators = require("src/validators"); const env = require("src/utils/env"); +const RuntimeConfig = require("src/config/runtime-config"); const { makeConfigStub } = require("../../utils"); describe("test-reader/build-instructions", () => { @@ -164,10 +165,28 @@ describe("test-reader/build-instructions", () => { }); describe("extendWithTimeout", () => { - it("should not add decorator to tree builder if 'testTimeout' is not specified in config", () => { - execTrapInstruction_(Instructions.extendWithTimeout, { config: {} }); + beforeEach(() => { + sandbox.stub(RuntimeConfig, "getInstance").returns({ replMode: { enabled: false } }); + }); - assert.notCalled(TreeBuilder.prototype.addTrap); + describe("should not add decorator to tree builder if", () => { + it("'testTimeout' is not specified in config", () => { + execTrapInstruction_(Instructions.extendWithTimeout, { config: {} }); + + assert.notCalled(TreeBuilder.prototype.addTrap); + }); + + it("'replMode' is enabled (even if 'testTimeout' is specified)", () => { + RuntimeConfig.getInstance.returns({ replMode: { enabled: true } }); + + execTrapInstruction_(Instructions.extendWithTimeout, { + config: { + testTimeout: 100500, + }, + }); + + assert.notCalled(TreeBuilder.prototype.addTrap); + }); }); it("should decorate with timeout if 'testTimeout' is specified in config", () => { diff --git a/test/src/test-reader/controllers/config-controller.js b/test/src/test-reader/controllers/config-controller.js index a4d48aae7..9e5d68eb8 100644 --- a/test/src/test-reader/controllers/config-controller.js +++ b/test/src/test-reader/controllers/config-controller.js @@ -1,9 +1,10 @@ "use strict"; +const { EventEmitter } = require("events"); const { ConfigController } = require("src/test-reader/controllers/config-controller"); const { TreeBuilder } = require("src/test-reader/tree-builder"); const { TestReaderEvents: ReadEvents } = require("src/events"); -const { EventEmitter } = require("events"); +const RuntimeConfig = require("src/config/runtime-config"); describe("test-reader/controllers/config-controller", () => { const sandbox = sinon.sandbox.create(); @@ -18,6 +19,7 @@ describe("test-reader/controllers/config-controller", () => { beforeEach(() => { sandbox.stub(TreeBuilder.prototype, "addTrap"); + sandbox.stub(RuntimeConfig, "getInstance").returns({ replMode: { enabled: false } }); }); afterEach(() => { @@ -25,6 +27,15 @@ describe("test-reader/controllers/config-controller", () => { }); describe("testTimeout", () => { + it("should do nothing if 'replMode' is enabled", () => { + RuntimeConfig.getInstance.returns({ replMode: { enabled: true } }); + const controller = mkController_(); + + controller.testTimeout(100500); + + assert.notCalled(TreeBuilder.prototype.addTrap); + }); + it("should set trap for the test object", () => { const controller = mkController_();