Skip to content

Commit 75eb516

Browse files
authored
test(core): supress Failure to parse stylesheet message from e2e test logs (#6263)
## Problem - JSDOM logs non-critical CSS parsing errors during E2E tests. These warnings occur when mynah-ui loads SCSS files in [main.ts](https://github.com/aws/mynah-ui/blob/8058f86ed370f5268ba6e0993b2436dca0e09b30/src/main.ts#L37). These errors appear the test logs but they do not affect test functionality or results. ## Solution - Suppress the errors --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 32c7b76 commit 75eb516

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

packages/amazonq/test/e2e/amazonq/framework/jsdomInjector.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,24 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { JSDOM } from 'jsdom'
6+
import { JSDOM, VirtualConsole } from 'jsdom'
77

8+
/**
9+
* JSDOM is used to help hoist MynahUI to running in a node environment vs in the browser (which is what it's made for)
10+
*/
811
export function injectJSDOM() {
9-
/**
10-
* JSDOM is used to help hoist MynahUI to running in a node environment vs in the browser (which is what it's made for)
11-
*/
12+
const virtualConsole = new VirtualConsole()
13+
virtualConsole.on('error', (error) => {
14+
// JSDOM can't load scss from mynah UI, just skip it
15+
if (!error.includes('Could not parse CSS stylesheet')) {
16+
console.error(error)
17+
}
18+
})
19+
1220
const dom = new JSDOM(undefined, {
1321
pretendToBeVisual: true,
1422
includeNodeLocations: true,
23+
virtualConsole,
1524
})
1625
global.window = dom.window as unknown as Window & typeof globalThis
1726
global.document = dom.window.document

0 commit comments

Comments
 (0)