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.
This commit is contained in:
lin onetwo 2026-01-26 01:25:58 +08:00
parent c9dcd2cc46
commit 9750ecc76f
2 changed files with 14 additions and 4 deletions

View file

@ -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,

View file

@ -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);