-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathjest.setupPerTest.js
21 lines (19 loc) · 997 Bytes
/
jest.setupPerTest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// eslint-disable-next-line import/no-extraneous-dependencies
const SetupAwaitedHandler = require('@ulixee/hero/lib/SetupAwaitedHandler');
// eslint-disable-next-line import/no-extraneous-dependencies
const DatastoreManifest = require('@ulixee/datastore-core/lib/DatastoreManifest').default;
// Jest tries to deeply recursively extract properties from objects when a test breaks - this does not play nice with AwaitedDom
const originGetProperty = SetupAwaitedHandler.delegate.getProperty;
SetupAwaitedHandler.delegate.getProperty = function getProperty(...args) {
const parentPath = new Error().stack;
if (parentPath.includes('deepCyclicCopy')) {
return null;
}
// eslint-disable-next-line prefer-rest-params
return originGetProperty(...args);
};
DatastoreManifest.prototype._save = DatastoreManifest.prototype.save;
jest.spyOn(DatastoreManifest.prototype, 'save').mockImplementation(async function save() {
if (this.source === 'global') return;
return await this._save();
});