chore: do not stall on actions when test timeout is 0 (#12418)
This commit is contained in:
parent
a612a3526a
commit
b79bb32c82
|
|
@ -18,7 +18,6 @@
|
||||||
import { debugMode } from './utils';
|
import { debugMode } from './utils';
|
||||||
|
|
||||||
export const DEFAULT_TIMEOUT = 30000;
|
export const DEFAULT_TIMEOUT = 30000;
|
||||||
const TIMEOUT = debugMode() ? 0 : DEFAULT_TIMEOUT;
|
|
||||||
|
|
||||||
export class TimeoutSettings {
|
export class TimeoutSettings {
|
||||||
private _parent: TimeoutSettings | undefined;
|
private _parent: TimeoutSettings | undefined;
|
||||||
|
|
@ -42,26 +41,32 @@ export class TimeoutSettings {
|
||||||
return options.timeout;
|
return options.timeout;
|
||||||
if (this._defaultNavigationTimeout !== undefined)
|
if (this._defaultNavigationTimeout !== undefined)
|
||||||
return this._defaultNavigationTimeout;
|
return this._defaultNavigationTimeout;
|
||||||
|
if (debugMode())
|
||||||
|
return 0;
|
||||||
if (this._defaultTimeout !== undefined)
|
if (this._defaultTimeout !== undefined)
|
||||||
return this._defaultTimeout;
|
return this._defaultTimeout;
|
||||||
if (this._parent)
|
if (this._parent)
|
||||||
return this._parent.navigationTimeout(options);
|
return this._parent.navigationTimeout(options);
|
||||||
return TIMEOUT;
|
return DEFAULT_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
timeout(options: { timeout?: number }): number {
|
timeout(options: { timeout?: number }): number {
|
||||||
if (typeof options.timeout === 'number')
|
if (typeof options.timeout === 'number')
|
||||||
return options.timeout;
|
return options.timeout;
|
||||||
|
if (debugMode())
|
||||||
|
return 0;
|
||||||
if (this._defaultTimeout !== undefined)
|
if (this._defaultTimeout !== undefined)
|
||||||
return this._defaultTimeout;
|
return this._defaultTimeout;
|
||||||
if (this._parent)
|
if (this._parent)
|
||||||
return this._parent.timeout(options);
|
return this._parent.timeout(options);
|
||||||
return TIMEOUT;
|
return DEFAULT_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static timeout(options: { timeout?: number }): number {
|
static timeout(options: { timeout?: number }): number {
|
||||||
if (typeof options.timeout === 'number')
|
if (typeof options.timeout === 'number')
|
||||||
return options.timeout;
|
return options.timeout;
|
||||||
return TIMEOUT;
|
if (debugMode())
|
||||||
|
return 0;
|
||||||
|
return DEFAULT_TIMEOUT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -285,8 +285,8 @@ export const test = _baseTest.extend<TestFixtures, WorkerFixtures>({
|
||||||
|
|
||||||
const onDidCreateBrowserContext = async (context: BrowserContext) => {
|
const onDidCreateBrowserContext = async (context: BrowserContext) => {
|
||||||
createdContexts.add(context);
|
createdContexts.add(context);
|
||||||
context.setDefaultTimeout(testInfo.timeout === 0 ? 0 : (actionTimeout || 0));
|
context.setDefaultTimeout(actionTimeout || 0);
|
||||||
context.setDefaultNavigationTimeout(testInfo.timeout === 0 ? 0 : (navigationTimeout || actionTimeout || 0));
|
context.setDefaultNavigationTimeout(navigationTimeout || actionTimeout || 0);
|
||||||
await startTracing(context.tracing);
|
await startTracing(context.tracing);
|
||||||
const listener = createInstrumentationListener(context);
|
const listener = createInstrumentationListener(context);
|
||||||
(context as any)._instrumentation.addListener(listener);
|
(context as any)._instrumentation.addListener(listener);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue