Skip to content

Commit 5336388

Browse files
committed
Make view tests run
1 parent 25bb51c commit 5336388

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

extensions/ql-vscode/src/view/jest.setup.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ Object.defineProperty(window, "matchMedia", {
1818
// Used by Primer React
1919
window.CSS.supports = jest.fn().mockResolvedValue(false);
2020

21+
// Functions that are not implemented in jsdom
22+
window.CSSStyleSheet.prototype.replaceSync = jest
23+
.fn()
24+
.mockReturnValue(undefined);
25+
window.ElementInternals.prototype.setFormValue = jest
26+
.fn()
27+
.mockReturnValue(undefined);
28+
window.ElementInternals.prototype.setValidity = jest
29+
.fn()
30+
.mockReturnValue(undefined);
31+
2132
// Store this on the window so we can mock it
2233
window.vsCodeApi = {
2334
postMessage: jest.fn(),

extensions/ql-vscode/test/jest-config.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
// These are all the packages that DO need to be transformed. All other packages will be ignored.
22
// These pacakges all use ES modules, so need to be transformed
3-
const transformScopes = ["@microsoft", "@octokit"];
3+
const transformScopes = [
4+
"@microsoft",
5+
"@octokit",
6+
"@vscode-elements",
7+
"@lit",
8+
"@lit-labs",
9+
];
410
const transformPackages = [
511
"@vscode/webview-ui-toolkit",
612
"before-after-hook",
@@ -11,13 +17,14 @@ const transformPackages = [
1117
"fetch-blob",
1218
"formdata-polyfill",
1319
"internmap",
20+
"lit",
1421
"nanoid",
1522
"p-queue",
1623
"p-timeout",
1724
"robust-predicates",
1825
"universal-user-agent",
1926
];
20-
const transformWildcards = ["d3-(.*)"];
27+
const transformWildcards = ["d3-(.*)", "lit-(.*)"];
2128
const transformPatterns = [
2229
...transformScopes.map((scope) => `${scope}/.+`),
2330
...transformPackages,

0 commit comments

Comments
 (0)