fix(test runner): disable expect, action and navigation timeouts on debug (#10958)
We disable these timeouts when test timeout is set to zero. This covers PWDEBUG=1, --debug and manual `test.setTimeout(0)` scenarios.
This commit is contained in:
parent
dd57843404
commit
93ad12978c
|
|
@ -189,8 +189,8 @@ export const test = _baseTest.extend<TestFixtures, WorkerFixtures>({
|
||||||
|
|
||||||
const onDidCreateContext = async (context: BrowserContext) => {
|
const onDidCreateContext = async (context: BrowserContext) => {
|
||||||
createdContexts.add(context);
|
createdContexts.add(context);
|
||||||
context.setDefaultTimeout(actionTimeout || 0);
|
context.setDefaultTimeout(testInfo.timeout === 0 ? 0 : (actionTimeout || 0));
|
||||||
context.setDefaultNavigationTimeout(navigationTimeout || actionTimeout || 0);
|
context.setDefaultNavigationTimeout(testInfo.timeout === 0 ? 0 : (navigationTimeout || actionTimeout || 0));
|
||||||
if (captureTrace) {
|
if (captureTrace) {
|
||||||
const title = [path.relative(testInfo.project.testDir, testInfo.file) + ':' + testInfo.line, ...testInfo.titlePath.slice(1)].join(' › ');
|
const title = [path.relative(testInfo.project.testDir, testInfo.file) + ':' + testInfo.line, ...testInfo.titlePath.slice(1)].join(' › ');
|
||||||
if (!(context.tracing as any)[kTracingStarted]) {
|
if (!(context.tracing as any)[kTracingStarted]) {
|
||||||
|
|
@ -207,8 +207,11 @@ export const test = _baseTest.extend<TestFixtures, WorkerFixtures>({
|
||||||
onApiCallBegin: (apiCall: string, stackTrace: ParsedStackTrace | null, userData: any) => {
|
onApiCallBegin: (apiCall: string, stackTrace: ParsedStackTrace | null, userData: any) => {
|
||||||
if (apiCall.startsWith('expect.'))
|
if (apiCall.startsWith('expect.'))
|
||||||
return { userObject: null };
|
return { userObject: null };
|
||||||
if (apiCall === 'page.pause')
|
if (apiCall === 'page.pause') {
|
||||||
testInfo.setTimeout(0);
|
testInfo.setTimeout(0);
|
||||||
|
context.setDefaultNavigationTimeout(0);
|
||||||
|
context.setDefaultTimeout(0);
|
||||||
|
}
|
||||||
const testInfoImpl = testInfo as any;
|
const testInfoImpl = testInfo as any;
|
||||||
const step = testInfoImpl._addStep({
|
const step = testInfoImpl._addStep({
|
||||||
location: stackTrace?.frames[0],
|
location: stackTrace?.frames[0],
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { currentTestInfo } from '../globals';
|
|
||||||
import type { Expect } from '../types';
|
import type { Expect } from '../types';
|
||||||
import { expectType } from '../util';
|
import { expectType } from '../util';
|
||||||
import { callLogText } from './toMatchText';
|
import { callLogText, currentExpectTimeout } from './toMatchText';
|
||||||
|
|
||||||
export async function toBeTruthy(
|
export async function toBeTruthy(
|
||||||
this: ReturnType<Expect['getState']>,
|
this: ReturnType<Expect['getState']>,
|
||||||
|
|
@ -34,11 +33,7 @@ export async function toBeTruthy(
|
||||||
promise: this.promise,
|
promise: this.promise,
|
||||||
};
|
};
|
||||||
|
|
||||||
const testInfo = currentTestInfo();
|
const timeout = currentExpectTimeout(options);
|
||||||
let defaultExpectTimeout = testInfo?.project.expect?.timeout;
|
|
||||||
if (typeof defaultExpectTimeout === 'undefined')
|
|
||||||
defaultExpectTimeout = 5000;
|
|
||||||
const timeout = options.timeout === 0 ? 0 : options.timeout || defaultExpectTimeout;
|
|
||||||
|
|
||||||
const { matches, log } = await query(this.isNot, timeout);
|
const { matches, log } = await query(this.isNot, timeout);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { currentTestInfo } from '../globals';
|
|
||||||
import type { Expect } from '../types';
|
import type { Expect } from '../types';
|
||||||
import { expectType } from '../util';
|
import { expectType } from '../util';
|
||||||
import { callLogText } from './toMatchText';
|
import { callLogText, currentExpectTimeout } from './toMatchText';
|
||||||
|
|
||||||
// Omit colon and one or more spaces, so can call getLabelPrinter.
|
// Omit colon and one or more spaces, so can call getLabelPrinter.
|
||||||
const EXPECTED_LABEL = 'Expected';
|
const EXPECTED_LABEL = 'Expected';
|
||||||
|
|
@ -43,11 +42,7 @@ export async function toEqual<T>(
|
||||||
promise: this.promise,
|
promise: this.promise,
|
||||||
};
|
};
|
||||||
|
|
||||||
const testInfo = currentTestInfo();
|
const timeout = currentExpectTimeout(options);
|
||||||
let defaultExpectTimeout = testInfo?.project.expect?.timeout;
|
|
||||||
if (typeof defaultExpectTimeout === 'undefined')
|
|
||||||
defaultExpectTimeout = 5000;
|
|
||||||
const timeout = options.timeout === 0 ? 0 : options.timeout || defaultExpectTimeout;
|
|
||||||
|
|
||||||
const { matches: pass, received, log } = await query(this.isNot, timeout);
|
const { matches: pass, received, log } = await query(this.isNot, timeout);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,11 +57,7 @@ export async function toMatchText(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const testInfo = currentTestInfo();
|
const timeout = currentExpectTimeout(options);
|
||||||
let defaultExpectTimeout = testInfo?.project.expect?.timeout;
|
|
||||||
if (typeof defaultExpectTimeout === 'undefined')
|
|
||||||
defaultExpectTimeout = 5000;
|
|
||||||
const timeout = options.timeout === 0 ? 0 : options.timeout || defaultExpectTimeout;
|
|
||||||
|
|
||||||
const { matches: pass, received, log } = await query(this.isNot, timeout);
|
const { matches: pass, received, log } = await query(this.isNot, timeout);
|
||||||
const stringSubstring = options.matchSubstring ? 'substring' : 'string';
|
const stringSubstring = options.matchSubstring ? 'substring' : 'string';
|
||||||
|
|
@ -124,3 +120,15 @@ Call log:
|
||||||
${colors.dim('- ' + (log || []).join('\n - '))}
|
${colors.dim('- ' + (log || []).join('\n - '))}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function currentExpectTimeout(options: { timeout?: number }) {
|
||||||
|
const testInfo = currentTestInfo();
|
||||||
|
if (testInfo && !testInfo.timeout)
|
||||||
|
return 0;
|
||||||
|
if (options.timeout !== undefined)
|
||||||
|
return options.timeout;
|
||||||
|
let defaultExpectTimeout = testInfo?.project.expect?.timeout;
|
||||||
|
if (typeof defaultExpectTimeout === 'undefined')
|
||||||
|
defaultExpectTimeout = 5000;
|
||||||
|
return defaultExpectTimeout;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue