Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cspotcode committed Oct 10, 2021
1 parent e2ca083 commit 7c3c09a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ export function getStream(stream: Readable, waitForPattern?: string | RegExp) {
}
}

const defaultRequireExtensions = captureObjectState(
require.extensions
);
const defaultRequireExtensions = captureObjectState(require.extensions);
const defaultProcess = captureObjectState(process);
const defaultModule = captureObjectState(require('module'));
const defaultError = captureObjectState(Error);
Expand Down Expand Up @@ -194,7 +192,7 @@ export function resetNodeEnvironment() {
function captureObjectState(object: any) {
return {
descriptors: Object.getOwnPropertyDescriptors(object),
values: {...object}
values: { ...object },
};
}
// Redefine all property descriptors and delete any new properties
Expand All @@ -209,8 +207,10 @@ function resetObject(
}
}
// Trigger nyc's setter functions
for(const [key, value] of Object.entries(state.values)) {
try { object[key] = value; } catch {}
for (const [key, value] of Object.entries(state.values)) {
try {
object[key] = value;
} catch {}
}
// Reset descriptors
Object.defineProperties(object, state.descriptors);
Expand Down

0 comments on commit 7c3c09a

Please sign in to comment.