diff --git a/package.json b/package.json index 0c1021bfab..f228140b99 100644 --- a/package.json +++ b/package.json @@ -237,7 +237,7 @@ "url-loader": "4.1.1", "utf8": "3.0.0", "uuid": "8.3.2", - "web-vitals": "1.1.2", + "web-vitals": "2.0.0", "webpack-isomorphic-tools": "4.0.0" }, "devDependencies": { diff --git a/tests/setup.js b/tests/setup.js index 7451f38554..7481aa62fd 100644 --- a/tests/setup.js +++ b/tests/setup.js @@ -88,6 +88,20 @@ global.fetch = (input) => { ); }; +// web-vitals library needs window.performance with getEntriesByName() +if (global.performance) { + if (global.performance.getEntriesByName) { + // If global.performance.getEntriesByName exists, that means we probably + // no longer need to mock it because it has been implemented in jsdom. + // throw an error so we can update the code. + throw new Error( + `Mocking of performance.getEntriesByName() seems to no longer be + necessary and should probably be removed`, + ); + } + global.performance.getEntriesByName = jest.fn().mockReturnValue([]); +} + afterEach(() => { global.sinon.restore(); }); diff --git a/yarn.lock b/yarn.lock index 46e31baef3..a5aaf27486 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13232,10 +13232,10 @@ watchpack@^2.0.0: glob-to-regexp "^0.4.1" graceful-fs "^4.1.2" -web-vitals@1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/web-vitals/-/web-vitals-1.1.2.tgz#06535308168986096239aa84716e68b4c6ae6d1c" - integrity sha512-PFMKIY+bRSXlMxVAQ+m2aw9c/ioUYfDgrYot0YUa+/xa0sakubWhSDyxAKwzymvXVdF4CZI71g06W+mqhzu6ig== +web-vitals@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/web-vitals/-/web-vitals-2.0.0.tgz#7fcfb5fd2f439c2936822573cb4d5e8e4caaa22b" + integrity sha512-aCB1sYxt2eeBufybFRrDQNBg2cOcq2f6Q1He7T+qPHAwpodDXhAoWwBUavwppQQ4kfUcT5eIAfjPc9PdqAxPEw== webidl-conversions@^4.0.2: version "4.0.2"