From 9750ecc76f7bf030ef2af82341bbc93e70504843 Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Mon, 26 Jan 2026 01:25:58 +0800 Subject: [PATCH] Move global timeout config to separate module Extracted global timeout setup from cucumber.config.js to features/supports/timeout-config.ts using setDefaultTimeout. This ensures the timeout is set via code rather than config, improving clarity and maintainability. --- features/cucumber.config.js | 7 +++---- features/supports/timeout-config.ts | 11 +++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 features/supports/timeout-config.ts diff --git a/features/cucumber.config.js b/features/cucumber.config.js index c21bd3c1..3f9bc5ec 100644 --- a/features/cucumber.config.js +++ b/features/cucumber.config.js @@ -9,6 +9,7 @@ module.exports = { default: { require: [ 'ts-node/register', + 'features/supports/timeout-config.ts', // Must be loaded first to set global timeout 'features/stepDefinitions/**/*.ts', ], requireModule: ['ts-node/register'], @@ -17,10 +18,8 @@ module.exports = { snippetInterface: 'async-await', }, paths: ['features/*.feature'], - // Global timeout for all steps - // Local: 5s, CI: 25s (5x local) - // Individual steps should NOT specify custom timeouts unless they have special needs - timeout: isCI ? 25000 : 5000, + // Note: Global timeout is set via setDefaultTimeout() in features/supports/timeout-config.ts + // NOT via the 'timeout' config option here (which is for Cucumber's own operations) // Parallel execution disabled due to OOM issues on Windows // Each scenario still gets isolated test-artifacts/{scenarioSlug}/ directory // parallel: 2, diff --git a/features/supports/timeout-config.ts b/features/supports/timeout-config.ts new file mode 100644 index 00000000..c82d0181 --- /dev/null +++ b/features/supports/timeout-config.ts @@ -0,0 +1,11 @@ +import { setDefaultTimeout } from '@cucumber/cucumber'; + +const isCI = Boolean(process.env.CI); + +// Set global timeout for all steps and hooks +// Local: 5s, CI: 25s +const globalTimeout = isCI ? 25000 : 5000; + +console.log('[Timeout Config] Setting global timeout to:', globalTimeout, 'ms (CI:', isCI, ')'); + +setDefaultTimeout(globalTimeout);