From 3277b6945addbe270f5b732c42662e6c36e59e98 Mon Sep 17 00:00:00 2001 From: Jeff Yates Date: Thu, 15 Feb 2024 11:36:08 -0600 Subject: [PATCH] [fixusageoutsidejest] Allow import outside of jest (#1018) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary: The `wait` function copied from Webapp verified that jest was in use at import. This worked when in webapp and it was just a file being imported, but now it's in Wonder Stuff Testing, it causes an error if any of the non-jest code is used outside of a jest environment, which is not what we want at all. So, this removes that module level check, which in turn means Wonder Stuff Testing can be used in non-jest contexts, like stories. See [Slack thread](https://khanacademy.slack.com/archives/CEA6W0F6F/p1707955461083099?thread_ts=1707867450.595019&cid=CEA6W0F6F) for more context, if you have access. Issue: XXX-XXXX ## Test plan: `yarn test` Once published, we can update webapp and verify `dataFactoryFor` is usable within stories. Author: somewhatabstract Reviewers: somewhatabstract, jeresig, evanchaney, jeremywiebe Required Reviewers: Approved By: jeresig Checks: ✅ Test (macos-latest, 20.x), ✅ codecov/project, ✅ CodeQL, ✅ Lint, typecheck, and coverage check (ubuntu-latest, 20.x), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ✅ Analyze (javascript), ✅ gerald, ⏭️ dependabot Pull Request URL: https://github.com/Khan/wonder-stuff/pull/1018 --- .changeset/chatty-cobras-roll.md | 5 +++++ packages/wonder-stuff-testing/src/jest/wait.ts | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 .changeset/chatty-cobras-roll.md diff --git a/.changeset/chatty-cobras-roll.md b/.changeset/chatty-cobras-roll.md new file mode 100644 index 00000000..0a8777d1 --- /dev/null +++ b/.changeset/chatty-cobras-roll.md @@ -0,0 +1,5 @@ +--- +"@khanacademy/wonder-stuff-testing": patch +--- + +Allow Wonder Stuff Testing to be imported outside of jest diff --git a/packages/wonder-stuff-testing/src/jest/wait.ts b/packages/wonder-stuff-testing/src/jest/wait.ts index 3ce85f4a..1a9875dd 100644 --- a/packages/wonder-stuff-testing/src/jest/wait.ts +++ b/packages/wonder-stuff-testing/src/jest/wait.ts @@ -1,8 +1,5 @@ import {verifyRealTimers} from "./internal/verify-real-timers"; import {unverifiedWait} from "./internal/unverified-wait"; -import {assertJest} from "./internal/assert-jest"; - -assertJest(); type WaitOptions = { /**