@trackunit/iris-app-playwright 0.1.27 → 0.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { expect } from "@playwright/test";
|
|
2
|
-
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions &
|
|
3
|
-
_harRecording: void;
|
|
4
|
-
} & import("./login.fixture").TrackunitBaseFixtures & import("./irisApp.fixture").IrisAppFixtures & import("./featureFlags.fixture").FeatureFlagFixtures & import("./localDevMode.fixture").LocalDevModeFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions & import("./login.fixture").LoginCacheFixtures>;
|
|
2
|
+
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & import("./login.fixture").TrackunitBaseFixtures & import("./irisApp.fixture").IrisAppFixtures & import("./featureFlags.fixture").FeatureFlagFixtures & import("./localDevMode.fixture").LocalDevModeFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions & import("./login.fixture").LoginCacheFixtures>;
|
|
5
3
|
export { expect };
|
|
6
4
|
export type { FeatureFlag, FeatureFlagFixtures } from "./featureFlags.fixture";
|
|
7
5
|
export type { IrisAppFixtures, IrisAppOptions, StorybookPreviewOptions } from "./irisApp.fixture";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Name of the per-test HAR file written by `recordHar` and read by `LogsReporter`. */
|
|
2
|
+
export declare const HAR_FILENAME = "test.har";
|
|
3
|
+
/**
|
|
4
|
+
* Minimal slice of Playwright's `TestInfo` needed to finalize HAR recording.
|
|
5
|
+
* Declared structurally so the behavior can be unit-tested without constructing
|
|
6
|
+
* a full `TestInfo`; the real `TestInfo` satisfies it.
|
|
7
|
+
*/
|
|
8
|
+
export interface HarTestInfo {
|
|
9
|
+
outputPath(...pathSegments: Array<string>): string;
|
|
10
|
+
attach(name: string, options: {
|
|
11
|
+
path: string;
|
|
12
|
+
}): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Attaches the per-test HAR (so it appears in the HTML report and is discoverable
|
|
16
|
+
* by `LogsReporter`), then deletes the original `recordHar` output file.
|
|
17
|
+
*
|
|
18
|
+
* `recordHar` writes the HAR to `testInfo.outputPath("test.har")`. `testInfo.attach`
|
|
19
|
+
* copies that file into Playwright's managed attachments location and points the
|
|
20
|
+
* attachment at the copy — which is the only path `LogsReporter` ever sees and
|
|
21
|
+
* cleans up (deleted on pass, redacted and retained on failure). The original file
|
|
22
|
+
* is left untouched, so without this deletion every test (passing included) leaks a
|
|
23
|
+
* `test.har` into the persisted workspace and stored CI artifacts, growing with the
|
|
24
|
+
* suite. Removing it here closes the leak while leaving the attachment copy for the
|
|
25
|
+
* reporter to retain on failure.
|
|
26
|
+
*/
|
|
27
|
+
export declare const finalizeHarRecording: (testInfo: HarTestInfo) => Promise<void>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.finalizeHarRecording = exports.HAR_FILENAME = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
/** Name of the per-test HAR file written by `recordHar` and read by `LogsReporter`. */
|
|
6
|
+
exports.HAR_FILENAME = "test.har";
|
|
7
|
+
/**
|
|
8
|
+
* Attaches the per-test HAR (so it appears in the HTML report and is discoverable
|
|
9
|
+
* by `LogsReporter`), then deletes the original `recordHar` output file.
|
|
10
|
+
*
|
|
11
|
+
* `recordHar` writes the HAR to `testInfo.outputPath("test.har")`. `testInfo.attach`
|
|
12
|
+
* copies that file into Playwright's managed attachments location and points the
|
|
13
|
+
* attachment at the copy — which is the only path `LogsReporter` ever sees and
|
|
14
|
+
* cleans up (deleted on pass, redacted and retained on failure). The original file
|
|
15
|
+
* is left untouched, so without this deletion every test (passing included) leaks a
|
|
16
|
+
* `test.har` into the persisted workspace and stored CI artifacts, growing with the
|
|
17
|
+
* suite. Removing it here closes the leak while leaving the attachment copy for the
|
|
18
|
+
* reporter to retain on failure.
|
|
19
|
+
*/
|
|
20
|
+
const finalizeHarRecording = async (testInfo) => {
|
|
21
|
+
const harPath = testInfo.outputPath(exports.HAR_FILENAME);
|
|
22
|
+
if (!(0, fs_1.existsSync)(harPath)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
await testInfo.attach("har", { path: harPath });
|
|
26
|
+
(0, fs_1.rmSync)(harPath, { force: true });
|
|
27
|
+
};
|
|
28
|
+
exports.finalizeHarRecording = finalizeHarRecording;
|
|
29
|
+
//# sourceMappingURL=finalizeHarRecording.js.map
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Adds Playwright HAR recording without
|
|
2
|
+
* Adds Playwright HAR recording without permanently leaking the per-test HAR.
|
|
3
3
|
*
|
|
4
|
-
* `contextOptions`
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* `recordHar` (configured via `contextOptions`) only flushes the HAR to disk when the
|
|
5
|
+
* browser context closes. Playwright tears fixtures down in reverse dependency order, so a
|
|
6
|
+
* fixture that merely *depends on* `context` is torn down BEFORE the built-in `context`
|
|
7
|
+
* fixture closes the context — at which point `testInfo.outputPath("test.har")` does not yet
|
|
8
|
+
* exist and any cleanup there is a no-op (this was the original leak: a `test.har` survived
|
|
9
|
+
* for every test). We therefore override `context` itself: after the test body we close the
|
|
10
|
+
* context to flush the HAR, then attach + clean it up via `finalizeHarRecording`. The
|
|
11
|
+
* built-in `context` teardown still runs afterwards — `close()` on an already-closed context
|
|
12
|
+
* is a no-op — so trace/video/screenshot retain-on-failure are unaffected.
|
|
9
13
|
*/
|
|
10
|
-
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions &
|
|
11
|
-
_harRecording: void;
|
|
12
|
-
}, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
|
|
14
|
+
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
|
|
@@ -2,34 +2,31 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.test = void 0;
|
|
4
4
|
const test_1 = require("@playwright/test");
|
|
5
|
-
const
|
|
6
|
-
const HAR_FILENAME = "test.har";
|
|
5
|
+
const finalizeHarRecording_1 = require("./finalizeHarRecording");
|
|
7
6
|
/**
|
|
8
|
-
* Adds Playwright HAR recording without
|
|
7
|
+
* Adds Playwright HAR recording without permanently leaking the per-test HAR.
|
|
9
8
|
*
|
|
10
|
-
* `contextOptions`
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
9
|
+
* `recordHar` (configured via `contextOptions`) only flushes the HAR to disk when the
|
|
10
|
+
* browser context closes. Playwright tears fixtures down in reverse dependency order, so a
|
|
11
|
+
* fixture that merely *depends on* `context` is torn down BEFORE the built-in `context`
|
|
12
|
+
* fixture closes the context — at which point `testInfo.outputPath("test.har")` does not yet
|
|
13
|
+
* exist and any cleanup there is a no-op (this was the original leak: a `test.har` survived
|
|
14
|
+
* for every test). We therefore override `context` itself: after the test body we close the
|
|
15
|
+
* context to flush the HAR, then attach + clean it up via `finalizeHarRecording`. The
|
|
16
|
+
* built-in `context` teardown still runs afterwards — `close()` on an already-closed context
|
|
17
|
+
* is a no-op — so trace/video/screenshot retain-on-failure are unaffected.
|
|
15
18
|
*/
|
|
16
19
|
exports.test = test_1.test.extend({
|
|
17
20
|
contextOptions: async ({ contextOptions }, provide, testInfo) => {
|
|
18
|
-
const harPath = testInfo.outputPath(HAR_FILENAME);
|
|
19
21
|
await provide({
|
|
20
22
|
...contextOptions,
|
|
21
|
-
recordHar: { path:
|
|
23
|
+
recordHar: { path: testInfo.outputPath(finalizeHarRecording_1.HAR_FILENAME), mode: "minimal" },
|
|
22
24
|
});
|
|
23
25
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
await testInfo.attach("har", { path: harPath });
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
{ auto: true },
|
|
33
|
-
],
|
|
26
|
+
context: async ({ context }, provide, testInfo) => {
|
|
27
|
+
await provide(context);
|
|
28
|
+
await context.close();
|
|
29
|
+
await (0, finalizeHarRecording_1.finalizeHarRecording)(testInfo);
|
|
30
|
+
},
|
|
34
31
|
});
|
|
35
32
|
//# sourceMappingURL=harRecording.fixture.js.map
|