Commit d37e8b7b authored by Paul Slaughter's avatar Paul Slaughter

Fix jest time reporting by resetting environment

parent cacdc619
...@@ -4,7 +4,10 @@ const path = require('path'); ...@@ -4,7 +4,10 @@ const path = require('path');
const { ErrorWithStack } = require('jest-util'); const { ErrorWithStack } = require('jest-util');
const JSDOMEnvironment = require('jest-environment-jsdom'); const JSDOMEnvironment = require('jest-environment-jsdom');
const { TEST_HOST } = require('./__helpers__/test_constants'); const { TEST_HOST } = require('./__helpers__/test_constants');
const { setGlobalDateToFakeDate } = require('./__helpers__/fake_date/fake_date'); const {
setGlobalDateToFakeDate,
setGlobalDateToRealDate,
} = require('./__helpers__/fake_date/fake_date');
const ROOT_PATH = path.resolve(__dirname, '../..'); const ROOT_PATH = path.resolve(__dirname, '../..');
...@@ -74,6 +77,9 @@ class CustomEnvironment extends JSDOMEnvironment { ...@@ -74,6 +77,9 @@ class CustomEnvironment extends JSDOMEnvironment {
} }
async teardown() { async teardown() {
// Reset `Date` so that Jest can report timing accurately *roll eyes*...
setGlobalDateToRealDate();
await new Promise(setImmediate); await new Promise(setImmediate);
if (this.rejectedPromises.length > 0) { if (this.rejectedPromises.length > 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment