@scenetest/playwright 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Michael Snook
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,36 @@
1
+ import { type Page } from '@playwright/test';
2
+ import type { AssertionResult } from '@scenetest/checks';
3
+ /**
4
+ * Extended page with scenetest assertion collection
5
+ */
6
+ export interface ScenePage extends Page {
7
+ /** All assertions collected during this test */
8
+ readonly assertions: AssertionResult[];
9
+ /** Assertions that passed */
10
+ readonly passed: AssertionResult[];
11
+ /** Assertions that failed */
12
+ readonly failed: AssertionResult[];
13
+ /**
14
+ * Wait for all pending multi-context assertions to complete.
15
+ * Use this after triggering actions that invoke assertion() calls.
16
+ */
17
+ waitForAssertions(options?: {
18
+ timeout?: number;
19
+ }): Promise<void>;
20
+ }
21
+ /**
22
+ * Scenetest fixtures for Playwright
23
+ */
24
+ export interface ScenetestFixtures {
25
+ /**
26
+ * A page with scenetest assertion collection enabled.
27
+ * All inline assertions (should/failed) called in the browser will be collected here.
28
+ */
29
+ scenePage: ScenePage;
30
+ }
31
+ /**
32
+ * Extended Playwright test with scenetest fixtures
33
+ */
34
+ export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & ScenetestFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
35
+ export { expect } from '@playwright/test';
36
+ //# sourceMappingURL=fixtures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../src/fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAExD;;GAEG;AACH,MAAM,WAAW,SAAU,SAAQ,IAAI;IACrC,gDAAgD;IAChD,QAAQ,CAAC,UAAU,EAAE,eAAe,EAAE,CAAA;IACtC,6BAA6B;IAC7B,QAAQ,CAAC,MAAM,EAAE,eAAe,EAAE,CAAA;IAClC,6BAA6B;IAC7B,QAAQ,CAAC,MAAM,EAAE,eAAe,EAAE,CAAA;IAClC;;;OAGG;IACH,iBAAiB,CAAC,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACjE;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,SAAS,EAAE,SAAS,CAAA;CACrB;AAED;;GAEG;AACH,eAAO,MAAM,IAAI,iQAyEf,CAAA;AAEF,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA"}
@@ -0,0 +1,66 @@
1
+ import { test as base } from '@playwright/test';
2
+ /**
3
+ * Extended Playwright test with scenetest fixtures
4
+ */
5
+ export const test = base.extend({
6
+ scenePage: async ({ page }, use) => {
7
+ const assertions = [];
8
+ // Expose the report function to the browser
9
+ // This will be called by should() and failed() in the app
10
+ await page.exposeFunction('__scenetest_report', (result) => {
11
+ assertions.push(result);
12
+ });
13
+ // Create the extended page object
14
+ const scenePage = page;
15
+ // Add getters for assertions
16
+ Object.defineProperty(scenePage, 'assertions', {
17
+ get: () => assertions,
18
+ });
19
+ Object.defineProperty(scenePage, 'passed', {
20
+ get: () => assertions.filter((a) => a.result === true),
21
+ });
22
+ Object.defineProperty(scenePage, 'failed', {
23
+ get: () => assertions.filter((a) => a.result === false),
24
+ });
25
+ scenePage.waitForAssertions = async (options) => {
26
+ const timeout = options?.timeout ?? 5000;
27
+ const startTime = Date.now();
28
+ const pollInterval = 50;
29
+ while (Date.now() - startTime < timeout) {
30
+ const pending = await page.evaluate(() => {
31
+ return typeof window.__scenetest_pending === 'function'
32
+ ? window.__scenetest_pending()
33
+ : 0;
34
+ });
35
+ if (pending === 0) {
36
+ return;
37
+ }
38
+ await new Promise((resolve) => setTimeout(resolve, pollInterval));
39
+ }
40
+ // Check one more time after timeout
41
+ const finalPending = await page.evaluate(() => {
42
+ return typeof window.__scenetest_pending === 'function'
43
+ ? window.__scenetest_pending()
44
+ : 0;
45
+ });
46
+ if (finalPending > 0) {
47
+ throw new Error(`waitForAssertions timed out after ${timeout}ms with ${finalPending} pending assertions`);
48
+ }
49
+ };
50
+ await use(scenePage);
51
+ // After the test, log any failed assertions
52
+ const failures = assertions.filter((a) => a.result === false);
53
+ if (failures.length > 0) {
54
+ console.log('\n--- Scenetest Inline Assertion Failures ---');
55
+ for (const failure of failures) {
56
+ console.log(` [${failure.type}] ${failure.description}`);
57
+ if (failure.stack) {
58
+ console.log(` at ${failure.stack.split('\n')[0]}`);
59
+ }
60
+ }
61
+ console.log('-------------------------------------------\n');
62
+ }
63
+ },
64
+ });
65
+ export { expect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YACxB,OAAO,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAA;YAC5D,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;gBAC/B,OAAO,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,WAAW,EAAE,CAAC,CAAA;gBACzD,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;oBAClB,OAAO,CAAC,GAAG,CAAC,UAAU,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;gBACvD,CAAC;YACH,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAA;QAC9D,CAAC;IACH,CAAC;CACF,CAAC,CAAA;AAEF,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { test, expect, type ScenePage, type ScenetestFixtures } from './fixtures.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,SAAS,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { test, expect } from './fixtures.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAA0C,MAAM,eAAe,CAAA"}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@scenetest/playwright",
3
+ "version": "0.1.1",
4
+ "description": "Playwright fixtures for scenetest inline assertions",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/scenetest/scenetest-js",
10
+ "directory": "packages/playwright-scenetest"
11
+ },
12
+ "keywords": [
13
+ "testing",
14
+ "e2e",
15
+ "playwright",
16
+ "assertions",
17
+ "inline-assertions",
18
+ "fixtures"
19
+ ],
20
+ "main": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "import": "./dist/index.js"
26
+ }
27
+ },
28
+ "files": [
29
+ "dist"
30
+ ],
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "dependencies": {
35
+ "@scenetest/checks": "0.1.1"
36
+ },
37
+ "peerDependencies": {
38
+ "@playwright/test": "^1.40.0"
39
+ },
40
+ "devDependencies": {
41
+ "@playwright/test": "^1.40.0",
42
+ "typescript": "^5.3.3"
43
+ },
44
+ "scripts": {
45
+ "build": "tsc",
46
+ "typecheck": "tsc --noEmit"
47
+ }
48
+ }