Compare commits

...

1 Commits

Author SHA1 Message Date
Uladzimir Havenchyk
2f57b90867 Replace lodash.clonedeep with structuredClone in FE 2024-02-20 22:11:55 +03:00
4 changed files with 16 additions and 6 deletions

View File

@@ -1,4 +1,3 @@
import cloneDeep from "lodash.clonedeep";
import _ from "underscore";
import * as Lib from "metabase-lib";
@@ -44,8 +43,8 @@ export function findColumnIndexForColumnSetting(
// we make a deep clone to unfreeze objects as
// cljs adds a unique id to every object
// and it's not possible with frozen objects
cloneDeep(columns),
[cloneDeep(normalizedFieldRef)],
structuredClone(columns),
[structuredClone(normalizedFieldRef)],
);
if (columnIndex >= 0) {

View File

@@ -45,7 +45,7 @@ const config = {
ace: {},
ga: {},
},
reporters: ['default', 'jest-junit'],
reporters: ["default", "jest-junit"],
coverageDirectory: "./coverage",
coverageReporters: ["html", "lcov"],
collectCoverageFrom: [
@@ -63,7 +63,7 @@ const config = {
"/target/cljs_release/",
"/frontend/test/",
],
testEnvironment: "jest-environment-jsdom",
testEnvironment: "<rootDir>/jest/jest-environment.js",
watchPlugins: [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname",

11
jest/jest-environment.js Normal file
View File

@@ -0,0 +1,11 @@
import JSDOMEnvironment from "jest-environment-jsdom";
import cloneDeep from "lodash.clonedeep";
// https://github.com/facebook/jest/blob/v29.4.3/website/versioned_docs/version-29.4/Configuration.md#testenvironment-string
export default class FixJSDOMEnvironment extends JSDOMEnvironment {
constructor(...args) {
super(...args);
// https://github.com/jsdom/jsdom/issues/3363
this.global.structuredClone = cloneDeep;
}
}

View File

@@ -66,7 +66,6 @@
"leaflet": "^1.2.0",
"leaflet-draw": "^0.4.9",
"leaflet.heat": "^0.2.0",
"lodash.clonedeep": "^4.5.0",
"lodash.debounce": "^4.0.8",
"moment-timezone": "^0.5.38",
"mustache": "^2.3.2",
@@ -253,6 +252,7 @@
"jsonwebtoken": "^9.0.0",
"knex": "^2.4.2",
"lint-staged": "^13.1.2",
"lodash.clonedeep": "^4.5.0",
"markdown-link-check": "^3.10.2",
"mini-css-extract-plugin": "2.7.2",
"mocha": "^10.2.0",