From 0f6cd54c15859ed6ddc329dc9d696fb0f35102c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kinen?= Date: Fri, 30 Aug 2024 09:25:40 +0300 Subject: [PATCH] Update Jest to fix tests after updating ol --- jest.config.js | 11 ++++------- package.json | 6 ++++-- tests/jest/fileTransformer.js | 4 +++- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/jest.config.js b/jest.config.js index 36f2cb6d4d..1db85e2717 100644 --- a/jest.config.js +++ b/jest.config.js @@ -10,14 +10,11 @@ module.exports = { '\\.(css|less)$': '/tests/jest/styleMock.js', '^d3$': '/node_modules/d3/dist/d3.min.js' }, - timers: 'fake', + fakeTimers: { + enableGlobally: true + }, verbose: true, transformIgnorePatterns: [ - 'node_modules/(?!(ol|jsts|geotiff|quick-lru)).+\\.js$' + 'node_modules/(?!(ol|color-parse|color-space|color-rgba|color-name|jsts|geotiff|quick-lru)).+\\.js$' ] - /* - ,transform: { - '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '/tests/jest/fileTransformer.js' - } - */ }; diff --git a/package.json b/package.json index 9c41afc8a0..3a6f70fad6 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "license": "(MIT OR EUPL-1.1)", "main": "grunt.js", "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0", + "node": ">=16.20.0", "npm": ">=6.0.0" }, "scripts": { @@ -44,6 +44,7 @@ "@testing-library/react": "12.1.5", "@testing-library/user-event": "14.4.3", "antd": "4.24.8", + "babel-jest": "29.7.0", "babel-loader": "8.3.0", "babel-plugin-styled-components": "2.1.4", "babel-plugin-transform-remove-strict-mode": "0.0.2", @@ -68,7 +69,8 @@ "gm": "1.23.1", "imports-loader": "0.8.0", "intl-messageformat": "9.11.4", - "jest": "27.0.6", + "jest": "29.7.0", + "jest-environment-jsdom": "29.7.0", "jquery": "3.7.1", "jsts": "2.2.0", "less": "3.9.0", diff --git a/tests/jest/fileTransformer.js b/tests/jest/fileTransformer.js index 9787619621..4a741770cd 100644 --- a/tests/jest/fileTransformer.js +++ b/tests/jest/fileTransformer.js @@ -3,6 +3,8 @@ const path = require('path'); // to fix static assest from being processed like import 'ol/ol.css'; module.exports = { process(src, filename, config, options) { - return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';'; + return { + code: 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';'; + } } };