@@ -80,3 +80,126 @@ window.addEventListener('afterprint', (event) => {
8080 // You can also use this event to send an AJAX request to a server for print tracking.
8181})
8282```
83+
84+ or listen for changes:
85+
86+ ``` typescript
87+ if (window .matchMedia ) {
88+ var mediaQueryList = window .matchMedia (' print' );
89+ mediaQueryList .addListener (function (mql ) {
90+ if (mql .matches ) {
91+ // Equivalent to onbeforeprint
92+ console .log (' Entering print mode (before print dialog)' );
93+ } else {
94+ // Equivalent to onafterprint
95+ console .log (' Exiting print mode (after print dialog)' );
96+ }
97+ });
98+ }
99+ ```
100+
101+ ``` bash
102+ 1) [mobile-chrome] › test/e2e/specs/01-smoke/critical-paths.spec.ts:38:3 › Critical Paths @smoke › @ready mobile navigation works across main pages
103+
104+ TimeoutError: page.waitForFunction: Timeout 15000ms exceeded.
105+
106+ at ../helpers/pageObjectModels/BasePage.ts:263
107+
108+ 261 | }
109+ 262 |
110+ > 263 | await this._page.waitForFunction(
111+ | ^
112+ 264 | () => {
113+ 265 | const header = document.getElementById(' header' )
114+ 266 | const menu = document.querySelector(' .main-nav-menu' )
115+ at BasePage.openMobileMenu (/home/kevin/Repos/WebstackBuilders/CorporateWebsite/astro.webstackbuilders.com/test/e2e/helpers/pageObjectModels/BasePage.ts:263:22)
116+ at /home/kevin/Repos/WebstackBuilders/CorporateWebsite/astro.webstackbuilders.com/test/e2e/specs/01-smoke/critical-paths.spec.ts:53:7
117+
118+ attachment # 1: screenshot (image/png) ──────────────────────────────────────────────────────────
119+ .cache/playwright/output/01-smoke-critical-paths-Cr-fda54-ion-works-across-main-pages-mobile-chrome/test-failed-1.png
120+ ────────────────────────────────────────────────────────────────────────────────────────────────
121+
122+ Error Context: .cache/playwright/output/01-smoke-critical-paths-Cr-fda54-ion-works-across-main-pages-mobile-chrome/error-context.md
123+
124+ 2) [mobile-safari] › test/e2e/specs/01-smoke/critical-paths.spec.ts:114:3 › Critical Paths @smoke › @ready main pages have no errors
125+
126+ Error: expect(received).toHaveLength(expected)
127+
128+ Expected length: 0
129+ Received length: 1
130+ Received array: [[Fetch API cannot load http: /localhost:4321/offline due to access control checks.]]
131+
132+ at ../helpers/pageObjectModels/BasePage.ts:665
133+
134+ 663 | const errors = await this._page.pageErrors ()
135+ 664 | const filteredErrors = errors.filter(( error) => ! this.isIgnorablePageError(error))
136+ > 665 | expect(filteredErrors).toHaveLength(0)
137+ | ^
138+ 666 | return filteredErrors
139+ 667 | }
140+ 668 |
141+ at BasePage.expectNoErrors (/home/kevin/Repos/WebstackBuilders/CorporateWebsite/astro.webstackbuilders.com/test/e2e/helpers/pageObjectModels/BasePage.ts:665:28)
142+ at /home/kevin/Repos/WebstackBuilders/CorporateWebsite/astro.webstackbuilders.com/test/e2e/specs/01-smoke/critical-paths.spec.ts:118:7
143+
144+ attachment # 1: screenshot (image/png) ──────────────────────────────────────────────────────────
145+ .cache/playwright/output/01-smoke-critical-paths-Cr-4a53f-y-main-pages-have-no-errors-mobile-safari/test-failed-1.png
146+ ────────────────────────────────────────────────────────────────────────────────────────────────
147+
148+ Error Context: .cache/playwright/output/01-smoke-critical-paths-Cr-4a53f-y-main-pages-have-no-errors-mobile-safari/error-context.md
149+
150+ 2 failed
151+ [mobile-chrome] › test/e2e/specs/01-smoke/critical-paths.spec.ts:38:3 › Critical Paths @smoke › @ready mobile navigation works across main pages
152+ [mobile-safari] › test/e2e/specs/01-smoke/critical-paths.spec.ts:114:3 › Critical Paths @smoke › @ready main pages have no errors
153+
154+
155+
156+ 1) [webkit] › test/e2e/specs/01-smoke/dynamic-pages.spec.ts:171:3 › Dynamic Pages @smoke › @ready dynamic pages have no console errors
157+
158+ Error: expect(received).toHaveLength(expected)
159+
160+ Expected length: 0
161+ Received length: 1
162+ Received array: [" Failed to load resource: the server responded with a status of 403 (Forbidden)" ]
163+
164+ 192 |
165+ 193 | // Fail if there are any unexpected 404s or errors
166+ > 194 | expect(errorChecker.getFilteredErrors ()).toHaveLength(0)
167+ | ^
168+ 195 | expect(errorChecker.getFiltered404s ()).toHaveLength(0)
169+ 196 | })
170+ 197 | })
171+ at /home/kevin/Repos/WebstackBuilders/CorporateWebsite/astro.webstackbuilders.com/test/e2e/specs/01-smoke/dynamic-pages.spec.ts:194:46
172+
173+ attachment # 1: screenshot (image/png) ──────────────────────────────────────────────────────────
174+ .cache/playwright/output/01-smoke-dynamic-pages-Dyn-8a015-ages-have-no-console-errors-webkit/test-failed-1.png
175+ ────────────────────────────────────────────────────────────────────────────────────────────────
176+
177+ Error Context: .cache/playwright/output/01-smoke-dynamic-pages-Dyn-8a015-ages-have-no-console-errors-webkit/error-context.md
178+
179+ 2) [mobile-safari] › test/e2e/specs/01-smoke/dynamic-pages.spec.ts:171:3 › Dynamic Pages @smoke › @ready dynamic pages have no console errors
180+
181+ Error: expect(received).toHaveLength(expected)
182+
183+ Expected length: 0
184+ Received length: 1
185+ Received array: [" Failed to load resource: the server responded with a status of 403 (Forbidden)" ]
186+
187+ 192 |
188+ 193 | // Fail if there are any unexpected 404s or errors
189+ > 194 | expect(errorChecker.getFilteredErrors ()).toHaveLength(0)
190+ | ^
191+ 195 | expect(errorChecker.getFiltered404s ()).toHaveLength(0)
192+ 196 | })
193+ 197 | })
194+ at /home/kevin/Repos/WebstackBuilders/CorporateWebsite/astro.webstackbuilders.com/test/e2e/specs/01-smoke/dynamic-pages.spec.ts:194:46
195+
196+ attachment # 1: screenshot (image/png) ──────────────────────────────────────────────────────────
197+ .cache/playwright/output/01-smoke-dynamic-pages-Dyn-8a015-ages-have-no-console-errors-mobile-safari/test-failed-1.png
198+ ────────────────────────────────────────────────────────────────────────────────────────────────
199+
200+ Error Context: .cache/playwright/output/01-smoke-dynamic-pages-Dyn-8a015-ages-have-no-console-errors-mobile-safari/error-context.md
201+
202+ 2 failed
203+ [webkit] › test/e2e/specs/01-smoke/dynamic-pages.spec.ts:171:3 › Dynamic Pages @smoke › @ready dynamic pages have no console errors
204+ [mobile-safari] › test/e2e/specs/01-smoke/dynamic-pages.spec.ts:171:3 › Dynamic Pages @smoke › @ready dynamic pages have no console errors
205+ ` ` `
0 commit comments