@molecule/app-e2e-fixtures-default 1.0.0

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,115 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship.
43
+
44
+ "Contribution" shall mean any work of authorship, including the
45
+ original version of the Work and any modifications or additions
46
+ to that Work, that is intentionally submitted to the Licensor for
47
+ inclusion in the Work by the copyright owner or by an individual or
48
+ Legal Entity authorized to submit on behalf of the copyright owner.
49
+
50
+ "Contributor" shall mean Licensor and any individual or Legal Entity
51
+ on behalf of whom a Contribution has been received by the Licensor and
52
+ subsequently incorporated within the Work.
53
+
54
+ 2. Grant of Copyright License. Subject to the terms and conditions of
55
+ this License, each Contributor hereby grants to You a perpetual,
56
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
57
+ copyright license to reproduce, prepare Derivative Works of,
58
+ publicly display, publicly perform, sublicense, and distribute the
59
+ Work and such Derivative Works in Source or Object form.
60
+
61
+ 3. Grant of Patent License. Subject to the terms and conditions of
62
+ this License, each Contributor hereby grants to You a perpetual,
63
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
64
+ patent license to make, have made, use, offer to sell, sell, import,
65
+ and otherwise transfer the Work.
66
+
67
+ 4. Redistribution. You may reproduce and distribute copies of the
68
+ Work or Derivative Works thereof in any medium, with or without
69
+ modifications, and in Source or Object form, provided that You
70
+ meet the following conditions:
71
+
72
+ (a) You must give any other recipients of the Work or
73
+ Derivative Works a copy of this License; and
74
+
75
+ (b) You must cause any modified files to carry prominent notices
76
+ stating that You changed the files; and
77
+
78
+ (c) You must retain, in the Source form of any Derivative Works
79
+ that You distribute, all copyright, patent, trademark, and
80
+ attribution notices from the Source form of the Work,
81
+ excluding those notices that do not pertain to any part of
82
+ the Derivative Works; and
83
+
84
+ (d) If the Work includes a "NOTICE" text file as part of its
85
+ distribution, then any Derivative Works that You distribute must
86
+ include a readable copy of the attribution notices contained
87
+ within such NOTICE file.
88
+
89
+ 5. Submission of Contributions.
90
+
91
+ 6. Trademarks. This License does not grant permission to use the trade
92
+ names, trademarks, service marks, or product names of the Licensor.
93
+
94
+ 7. Disclaimer of Warranty. Unless required by applicable law or
95
+ agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
96
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
97
+
98
+ 8. Limitation of Liability. In no event and under no legal theory shall
99
+ any Contributor be liable to You for damages.
100
+
101
+ 9. Accepting Warranty or Additional Liability.
102
+
103
+ Copyright 2026 Molecule Dev, Inc.
104
+
105
+ Licensed under the Apache License, Version 2.0 (the "License");
106
+ you may not use this file except in compliance with the License.
107
+ You may obtain a copy of the License at
108
+
109
+ http://www.apache.org/licenses/LICENSE-2.0
110
+
111
+ Unless required by applicable law or agreed to in writing, software
112
+ distributed under the License is distributed on an "AS IS" BASIS,
113
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
114
+ See the License for the specific language governing permissions and
115
+ limitations under the License.
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Shared Playwright `test` + `expect` with auto-attached browser
3
+ * console-error / pageerror guard.
4
+ *
5
+ * Every fleet app's e2e specs import `test` and `expect` from this
6
+ * module (re-exported through their per-app `_helpers.ts`) instead of
7
+ * `@playwright/test` directly. The custom `test` includes a
8
+ * `consoleGuard` fixture with `{ auto: true }`, so every test
9
+ * automatically subscribes to the browser's `pageerror` event and
10
+ * `console.error` messages, then asserts the buffer is empty at test
11
+ * teardown.
12
+ *
13
+ * This catches the failure mode where React (or any other client-side
14
+ * module) throws on mount but the spec only asserts against
15
+ * `page.request.get/post`, leaving the test green while the rendered
16
+ * page is blank. A single quill-delta ESM/CJS interop error sat for
17
+ * four days like this before we noticed — the replay videos were
18
+ * 17 KB of nothing and the JSON reported PASS.
19
+ *
20
+ * To intentionally let a known error through (rare — almost always a
21
+ * smell that should be fixed in the app), use
22
+ * `test.info().annotations.push({ type: 'allow-console-error', description: 'why' })`
23
+ * inside the test body BEFORE the error fires. The `description` is
24
+ * matched against the error text as a regular expression; if it is not
25
+ * a valid regex it is matched as a plain substring instead (so literal
26
+ * error text with `[`/`(` can be pasted verbatim). An annotation with
27
+ * no description allows every error — always provide one.
28
+ *
29
+ * A small, fixed set of browser-noise patterns are ALWAYS ignored regardless
30
+ * of `allow-console-error` (Vite HMR reconnect chatter, service-worker 404s
31
+ * in headless Chrome, and a real Chrome DevTools "failed to load SourceMap"
32
+ * message for any `https://`-hosted bundle — e.g. Stripe/Google Maps CDN
33
+ * scripts shipped without source maps). That last pattern is verified
34
+ * against the actual Chrome message text and constrained to `https://` so it
35
+ * can never silence a genuinely broken source map in the app's OWN bundle
36
+ * (served over plain `http://localhost` in dev/preview).
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * // In fleet apps, the per-app `./_helpers.ts` re-exports these:
41
+ * import { test, expect } from '@molecule/app-e2e-fixtures-default'
42
+ *
43
+ * test('login lands on dashboard', async ({ page }) => {
44
+ * await page.goto('/login')
45
+ * await page.getByLabel(/email/i).fill('user@example.com')
46
+ * // ...
47
+ * })
48
+ * ```
49
+ *
50
+ * @module
51
+ */
52
+ import { expect } from '@playwright/test';
53
+ interface ConsoleErrorEntry {
54
+ type: 'pageerror' | 'console.error';
55
+ text: string;
56
+ location?: string;
57
+ }
58
+ /**
59
+ * Custom Playwright `test` with an auto-attached browser console-error
60
+ * guard. Drop-in replacement for `import { test } from '@playwright/test'`.
61
+ */
62
+ export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & {
63
+ consoleGuard: void;
64
+ }, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
65
+ export { expect };
66
+ export type { ConsoleErrorEntry };
67
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,OAAO,EAAuB,MAAM,EAAgB,MAAM,kBAAkB,CAAA;AAE5E,UAAU,iBAAiB;IACzB,IAAI,EAAE,WAAW,GAAG,eAAe,CAAA;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAkCD;;;GAGG;AACH,eAAO,MAAM,IAAI;kBAA+B,IAAI;wGAkElD,CAAA;AAEF,OAAO,EAAE,MAAM,EAAE,CAAA;AACjB,YAAY,EAAE,iBAAiB,EAAE,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Shared Playwright `test` + `expect` with auto-attached browser
3
+ * console-error / pageerror guard.
4
+ *
5
+ * Every fleet app's e2e specs import `test` and `expect` from this
6
+ * module (re-exported through their per-app `_helpers.ts`) instead of
7
+ * `@playwright/test` directly. The custom `test` includes a
8
+ * `consoleGuard` fixture with `{ auto: true }`, so every test
9
+ * automatically subscribes to the browser's `pageerror` event and
10
+ * `console.error` messages, then asserts the buffer is empty at test
11
+ * teardown.
12
+ *
13
+ * This catches the failure mode where React (or any other client-side
14
+ * module) throws on mount but the spec only asserts against
15
+ * `page.request.get/post`, leaving the test green while the rendered
16
+ * page is blank. A single quill-delta ESM/CJS interop error sat for
17
+ * four days like this before we noticed — the replay videos were
18
+ * 17 KB of nothing and the JSON reported PASS.
19
+ *
20
+ * To intentionally let a known error through (rare — almost always a
21
+ * smell that should be fixed in the app), use
22
+ * `test.info().annotations.push({ type: 'allow-console-error', description: 'why' })`
23
+ * inside the test body BEFORE the error fires. The `description` is
24
+ * matched against the error text as a regular expression; if it is not
25
+ * a valid regex it is matched as a plain substring instead (so literal
26
+ * error text with `[`/`(` can be pasted verbatim). An annotation with
27
+ * no description allows every error — always provide one.
28
+ *
29
+ * A small, fixed set of browser-noise patterns are ALWAYS ignored regardless
30
+ * of `allow-console-error` (Vite HMR reconnect chatter, service-worker 404s
31
+ * in headless Chrome, and a real Chrome DevTools "failed to load SourceMap"
32
+ * message for any `https://`-hosted bundle — e.g. Stripe/Google Maps CDN
33
+ * scripts shipped without source maps). That last pattern is verified
34
+ * against the actual Chrome message text and constrained to `https://` so it
35
+ * can never silence a genuinely broken source map in the app's OWN bundle
36
+ * (served over plain `http://localhost` in dev/preview).
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * // In fleet apps, the per-app `./_helpers.ts` re-exports these:
41
+ * import { test, expect } from '@molecule/app-e2e-fixtures-default'
42
+ *
43
+ * test('login lands on dashboard', async ({ page }) => {
44
+ * await page.goto('/login')
45
+ * await page.getByLabel(/email/i).fill('user@example.com')
46
+ * // ...
47
+ * })
48
+ * ```
49
+ *
50
+ * @module
51
+ */
52
+ import { expect, test as base } from '@playwright/test';
53
+ /** Substrings that are always ignored — browser noise that doesn't reflect app bugs. */
54
+ const ALWAYS_IGNORE = [
55
+ // Vite HMR dev-only websocket reconnect warnings — happen on the
56
+ // test runner's first poll before vite is fully booted; harmless.
57
+ /\[vite\].*connecting/i,
58
+ /\[vite\].*server connection lost/i,
59
+ // Service worker registration failures in headless Chrome — VitePWA
60
+ // tries to register at /sw.js but our smoke build emits to /workbox-*
61
+ // and Playwright fixtures the user-agent. Cosmetic.
62
+ /service worker.*404/i,
63
+ // Chrome DevTools' own probe for source maps on third-party CDN bundles
64
+ // we don't ship maps for (Stripe, Google Maps, etc). Two bugs fixed here,
65
+ // both verified against a headless Chromium probe + the real reported
66
+ // message text (not guessed): (1) the verb was wrong — real Chrome output
67
+ // is "DevTools failed to load SourceMap: Could not load content for
68
+ // <url>: ...", not "failed to fetch source map", so the old pattern never
69
+ // matched real Chrome text at all; (2) the host check (`.cdn.`) doesn't
70
+ // match real vendor hosts (js.stripe.com, maps.googleapis.com contain no
71
+ // '.cdn.' substring). Now matches any `https://`-hosted source map
72
+ // (third-party CDN bundles are always TLS; the app's own dev/preview
73
+ // server is plain `http://localhost`, so same-origin source-map issues
74
+ // are never accidentally silenced by this pattern).
75
+ // NOTE (verified, not assumed): a probe with a broken `sourceMappingURL`
76
+ // produced ZERO console messages via `page.on('console')` under plain
77
+ // Playwright automation (with and without tracing) — Chrome only fetches
78
+ // source maps when a DevTools Sources panel is actually attached, which a
79
+ // headless Playwright run never does. So this entry currently matches
80
+ // nothing observed in practice; it is defense-in-depth against a future
81
+ // Chrome/Playwright behavior change, not an active filter today.
82
+ /devtools failed to load source ?map.*https:\/\//i,
83
+ ];
84
+ /**
85
+ * Custom Playwright `test` with an auto-attached browser console-error
86
+ * guard. Drop-in replacement for `import { test } from '@playwright/test'`.
87
+ */
88
+ export const test = base.extend({
89
+ consoleGuard: [
90
+ async ({ page }, use, testInfo) => {
91
+ const buffer = [];
92
+ // Each allow-console-error description is tried as a regex; an invalid
93
+ // pattern (e.g. verbatim error text containing `[` or `(`) falls back to
94
+ // plain substring matching instead of throwing from inside the guard.
95
+ const matchesAllowed = (text, description) => {
96
+ if (description === undefined)
97
+ return true; // no description = allow everything
98
+ try {
99
+ return new RegExp(description).test(text);
100
+ }
101
+ catch (_error) {
102
+ // Invalid regex — treat the description as a literal substring.
103
+ return text.includes(description);
104
+ }
105
+ };
106
+ const shouldIgnore = (text) => {
107
+ if (ALWAYS_IGNORE.some((re) => re.test(text)))
108
+ return true;
109
+ return testInfo.annotations
110
+ .filter((a) => a.type === 'allow-console-error')
111
+ .some((a) => matchesAllowed(text, a.description));
112
+ };
113
+ const onPageError = (err) => {
114
+ const text = err.message || String(err);
115
+ if (shouldIgnore(text))
116
+ return;
117
+ buffer.push({ type: 'pageerror', text });
118
+ };
119
+ const onConsole = (msg) => {
120
+ if (msg.type() !== 'error')
121
+ return;
122
+ const text = msg.text();
123
+ if (shouldIgnore(text))
124
+ return;
125
+ const loc = msg.location();
126
+ buffer.push({
127
+ type: 'console.error',
128
+ text,
129
+ location: loc?.url ? `${loc.url}:${loc.lineNumber}` : undefined,
130
+ });
131
+ };
132
+ page.on('pageerror', onPageError);
133
+ page.on('console', onConsole);
134
+ try {
135
+ await use();
136
+ }
137
+ finally {
138
+ page.off('pageerror', onPageError);
139
+ page.off('console', onConsole);
140
+ }
141
+ if (buffer.length > 0) {
142
+ const lines = buffer
143
+ .map((e) => ` - [${e.type}] ${e.text}${e.location ? ` (${e.location})` : ''}`)
144
+ .join('\n');
145
+ throw new Error(`Browser console error(s) during test (${buffer.length}):\n${lines}\n\n` +
146
+ `If this error is genuinely expected, add\n` +
147
+ ` test.info().annotations.push({ type: 'allow-console-error', description: '<regex>' })\n` +
148
+ `to the test body BEFORE the error fires.`);
149
+ }
150
+ },
151
+ { auto: true },
152
+ ],
153
+ });
154
+ export { expect };
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@molecule/app-e2e-fixtures-default",
3
+ "version": "1.0.0",
4
+ "description": "Shared Playwright `test` + `expect` with auto-attached browser console-error/pageerror guard. Every fleet app's e2e specs import from here so a runtime exception (React mount failure, ESM/CJS interop error, unhandled rejection) hard-fails the test instead of silently passing.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "test": "vitest run",
11
+ "test:watch": "vitest"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "keywords": [
23
+ "molecule",
24
+ "playwright",
25
+ "e2e",
26
+ "fixtures",
27
+ "console-errors"
28
+ ],
29
+ "license": "Apache-2.0",
30
+ "devDependencies": {
31
+ "@playwright/test": "1.62.0",
32
+ "@types/node": "26.1.2",
33
+ "typescript": "6.0.3",
34
+ "vitest": "4.1.10"
35
+ },
36
+ "peerDependencies": {
37
+ "@playwright/test": "^1.50.0"
38
+ },
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "https://github.com/molecule-dev/molecule.git",
42
+ "directory": "packages/app/features/e2e-fixtures-default"
43
+ },
44
+ "homepage": "https://github.com/molecule-dev/molecule/tree/main/packages/app/features/e2e-fixtures-default",
45
+ "bugs": "https://github.com/molecule-dev/molecule/issues",
46
+ "publishConfig": {
47
+ "access": "public"
48
+ }
49
+ }