From 7d1ae39080dd0b85da03ad56610682ecb1d38f8e Mon Sep 17 00:00:00 2001 From: Joel Einbinder Date: Tue, 14 Sep 2021 12:09:42 -0400 Subject: [PATCH] feat(test runner): add some fixture debugging --- src/test/fixtures.ts | 4 +++- src/test/util.ts | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/fixtures.ts b/src/test/fixtures.ts index 9f31527d62fe4..59bbcf607ac56 100644 --- a/src/test/fixtures.ts +++ b/src/test/fixtures.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { formatLocation, wrapInPromise } from './util'; +import { formatLocation, wrapInPromise, debugTest } from './util'; import * as crypto from 'crypto'; import { FixturesWithLocation, Location, WorkerInfo, TestInfo, TestStepInternal } from './types'; @@ -67,6 +67,7 @@ class Fixture { let called = false; const setupFence = new Promise((f, r) => { setupFenceFulfill = f; setupFenceReject = r; }); const teardownFence = new Promise(f => this._teardownFenceCallback = f); + debugTest(`setup ${this.registration.name}`); this._tearDownComplete = wrapInPromise(this.registration.fn(params, async (value: any) => { if (called) throw new Error(`Cannot provide fixture value for the second time`); @@ -94,6 +95,7 @@ class Fixture { await fixture.teardown(); this.usages.clear(); if (this._setup) { + debugTest(`teardown ${this.registration.name}`); this._teardownFenceCallback(); await this._tearDownComplete; } diff --git a/src/test/util.ts b/src/test/util.ts index 98ec3acbb17d9..d7c9be95c7d4f 100644 --- a/src/test/util.ts +++ b/src/test/util.ts @@ -20,6 +20,7 @@ import path from 'path'; import type { TestError, Location } from './types'; import { default as minimatch } from 'minimatch'; import { errors } from '../..'; +import debug from 'debug'; export async function pollUntilDeadline(testInfo: TestInfoImpl, func: (remainingTime: number) => Promise, pollTime: number | undefined, deadlinePromise: Promise): Promise { let defaultExpectTimeout = testInfo.project.expect?.timeout; @@ -167,3 +168,5 @@ export function expectType(receiver: any, type: string, matcherName: string) { export function sanitizeForFilePath(s: string) { return s.replace(/[\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/g, '-'); } + +export const debugTest = debug('pw:test');