Skip to content

Commit 31a0e0e

Browse files
committed
test: adjust jest to recently updated elastic/charts
Signed-off-by: Tomasz Kania <tomasz.kania@pl.ibm.com>
1 parent ec5cc09 commit 31a0e0e

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"resolutions": {
4646
"ansi-regex": "^5.0.1",
4747
"qs": "^6.15.2",
48-
"uuid": "^11.1.1"
48+
"**/@cypress/request/uuid": "^11.1.1"
4949
},
5050
"engines": {
5151
"yarn": "^1.21.1"

test/jest.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ module.exports = {
6565
'^.+\\.html$': '<rootDir>/test/utils/mockTransform.js',
6666
},
6767
transformIgnorePatterns: [
68-
// ignore all node_modules except d3-color which requires babel transforms to handle export statement
69-
// since ESM modules are not natively supported in Jest yet (https://github.com/facebook/jest/issues/4842)
70-
'[/\\\\]node_modules(?![\\/\\\\](monaco-editor|react-monaco-editor|weak-lru-cache|ordered-binary|d3-color|axios|uuid|query-string|decode-uri-component|filter-obj|split-on-first))[/\\\\].+\\.js$',
68+
// ignore all node_modules except packages that require babel transforms to handle export statements,
69+
// including nested dependencies resolved from parent node_modules directories
70+
String.raw`[/\\]node_modules[/\\](?!((?:@[^/\\]+[/\\])?[^/\\]+[/\\])*?(monaco-editor|react-monaco-editor|weak-lru-cache|ordered-binary|d3-color|axios|uuid|query-string|decode-uri-component|filter-obj|split-on-first)([/\\]|$))`,
7171
],
7272
};

test/setup.jest.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ Object.defineProperty(window, 'matchMedia', {
4646
})),
4747
});
4848

49+
// jsdom does not provide ResizeObserver, but EUI / elastic-charts instantiate it at render time.
50+
class ResizeObserver {
51+
observe() {}
52+
unobserve() {}
53+
disconnect() {}
54+
}
55+
56+
window.ResizeObserver = ResizeObserver;
57+
global.ResizeObserver = ResizeObserver;
58+
4959
// jsdom 26 marks window.localStorage and window.sessionStorage as non-configurable.
5060
// Re-declare them as configurable once here so individual tests can override them
5161
// with Object.defineProperty without hitting "Cannot redefine property" errors.

0 commit comments

Comments
 (0)