Update dependency web-vitals to v2 (#10640)

* Update dependency web-vitals to v2

* Mock performance.getEntriesByName() in tests

* Only patch the method in window.performance if the object is already present

* Update tests/setup.js

Co-authored-by: William Durand <will+git@drnd.me>

* Throw an error if mocked method was already there for the future, and mock to return a list

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Mathieu Pillard <mpillard@mozilla.com>
Co-authored-by: Mathieu Pillard <diox@users.noreply.github.com>
Co-authored-by: William Durand <will+git@drnd.me>
This commit is contained in:
renovate[bot] 2021-06-02 15:42:34 +02:00 коммит произвёл GitHub
Родитель f380025092
Коммит a80b0344cf
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 19 добавлений и 5 удалений

Просмотреть файл

@ -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": {

Просмотреть файл

@ -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();
});

Просмотреть файл

@ -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"