Jest update v26.6.3 -> v29.5.1

Summary:
^

Basically, update Jest and fix any raised issues. Mainly:
- Update necessary dependencies
- Update snapshots
- `useFakeTimers` caused a few issues which meant that the way we hook into the performance object had to be tweaked. The main code change is: `//fbsource/xplat/sonar/desktop/scripts/jest-setup-after.tsx`
- `mocked` -> `jest.mocked`

Changelog: Update Jest to v29.5.1

Reviewed By: antonk52

Differential Revision: D46319818

fbshipit-source-id: d218ca8f7e43abac6b00844953ddeb7f4e1010a2
This commit is contained in:
Lorenzo Blasa
2023-05-31 14:19:29 -07:00
committed by Facebook GitHub Bot
parent 94cb8935b2
commit 6430403da0
40 changed files with 1721 additions and 1787 deletions

View File

@@ -63,17 +63,51 @@ console.debug = function () {
};
// make perf tools available in Node (it is available in Browser / Electron just fine)
const {PerformanceObserver, performance} = require('perf_hooks');
Object.freeze(performance);
Object.freeze(Object.getPrototypeOf(performance));
import {PerformanceObserver, performance} from 'perf_hooks';
// Object.freeze(performance);
// Object.freeze(Object.getPrototypeOf(performance));
// Something in our unit tests is messing with the performance global
// This fixes that.....
// This fixes that.
let _performance = performance;
Object.defineProperty(global, 'performance', {
get() {
return performance;
return _performance;
},
set() {
throw new Error('Attempt to overwrite global.performance');
set(value) {
_performance = value;
if (typeof _performance.mark === 'undefined') {
_performance.mark = (_markName: string, _markOptions?) => {
return {
name: '',
detail: '',
duration: 0,
entryType: '',
startTime: 0,
toJSON() {},
};
};
}
if (typeof _performance.clearMarks === 'undefined') {
_performance.clearMarks = () => {};
}
if (typeof _performance.measure === 'undefined') {
_performance.measure = (
_measureName: string,
_startOrMeasureOptions?,
_endMark?: string | undefined,
) => {
return {
name: '',
detail: '',
duration: 0,
entryType: '',
startTime: 0,
toJSON() {},
};
};
}
},
});