Skip to content

Commit 6476c43

Browse files
committed
test: enhance jest test setup and add documentation structure
Add vscrui to jest transform ignore patterns Add crypto.getRandomValues mock for tests Initialize cline documentation structure with required files
1 parent 40fd397 commit 6476c43

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

webview-ui/config-overrides.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports.jest = function(config) {
1515

1616
// Configure transform ignore patterns for ES modules
1717
config.transformIgnorePatterns = [
18-
'/node_modules/(?!(rehype-highlight|react-remark|unist-util-visit|unist-util-find-after|vfile|unified|bail|is-plain-obj|trough|vfile-message|unist-util-stringify-position|mdast-util-from-markdown|mdast-util-to-string|micromark|decode-named-character-reference|character-entities|markdown-table|zwitch|longest-streak|escape-string-regexp|unist-util-is|hast-util-to-text|@vscode/webview-ui-toolkit|@microsoft/fast-react-wrapper|@microsoft/fast-element|@microsoft/fast-foundation|@microsoft/fast-web-utilities|exenv-es6)/)'
18+
'/node_modules/(?!(rehype-highlight|react-remark|unist-util-visit|unist-util-find-after|vfile|unified|bail|is-plain-obj|trough|vfile-message|unist-util-stringify-position|mdast-util-from-markdown|mdast-util-to-string|micromark|decode-named-character-reference|character-entities|markdown-table|zwitch|longest-streak|escape-string-regexp|unist-util-is|hast-util-to-text|@vscode/webview-ui-toolkit|@microsoft/fast-react-wrapper|@microsoft/fast-element|@microsoft/fast-foundation|@microsoft/fast-web-utilities|exenv-es6|vscrui)/)'
1919
];
2020

2121
return config;

webview-ui/src/setupTests.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
import '@testing-library/jest-dom';
22

3-
// Mock window.matchMedia
3+
// Mock crypto.getRandomValues
4+
Object.defineProperty(window, 'crypto', {
5+
value: {
6+
getRandomValues: function(buffer: Uint8Array) {
7+
for (let i = 0; i < buffer.length; i++) {
8+
buffer[i] = Math.floor(Math.random() * 256);
9+
}
10+
return buffer;
11+
}
12+
}
13+
});
14+
15+
// Mock matchMedia
416
Object.defineProperty(window, 'matchMedia', {
517
writable: true,
618
value: jest.fn().mockImplementation(query => ({
719
matches: false,
820
media: query,
921
onchange: null,
10-
addListener: jest.fn(), // Deprecated
11-
removeListener: jest.fn(), // Deprecated
22+
addListener: jest.fn(), // deprecated
23+
removeListener: jest.fn(), // deprecated
1224
addEventListener: jest.fn(),
1325
removeEventListener: jest.fn(),
1426
dispatchEvent: jest.fn(),

0 commit comments

Comments
 (0)