Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fixusageoutsidejest] Allow import outside of jest #1018

Merged
merged 1 commit into from
Feb 15, 2024

Conversation

somewhatabstract
Copy link
Member

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 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.

@somewhatabstract somewhatabstract self-assigned this Feb 15, 2024
Copy link

changeset-bot bot commented Feb 15, 2024

🦋 Changeset detected

Latest commit: ed94c9c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@khanacademy/wonder-stuff-testing Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@khan-actions-bot khan-actions-bot requested a review from a team February 15, 2024 01:03
@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/frontend-infra for changes to .changeset/chatty-cobras-roll.md, packages/wonder-stuff-testing/src/jest/wait.ts

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

@@ -1,8 +1,5 @@
import {verifyRealTimers} from "./internal/verify-real-timers";
import {unverifiedWait} from "./internal/unverified-wait";
import {assertJest} from "./internal/assert-jest";

assertJest();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: The wait call invokes a verifyRealTimers call, which in turn will call assertJest so we're still covered, just not at import time.

Copy link

codecov bot commented Feb 15, 2024

Codecov Report

Merging #1018 (ed94c9c) into main (d588332) will increase coverage by 0.07%.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1018      +/-   ##
==========================================
+ Coverage   99.85%   99.92%   +0.07%     
==========================================
  Files          97       97              
  Lines        1393     1389       -4     
  Branches      359      343      -16     
==========================================
- Hits         1391     1388       -3     
  Misses          1        1              
+ Partials        1        0       -1     
Files Coverage Δ
packages/wonder-stuff-testing/src/jest/wait.ts 100.00% <ø> (ø)

... and 3 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d588332...ed94c9c. Read the comment docs.

Copy link
Contributor

Size Change: -2 B (0%)

Total Size: 4.66 kB

Filename Size Change
packages/wonder-stuff-testing/dist/browser/es/index.js 1.13 kB -2 B (0%)
ℹ️ View Unchanged
Filename Size
packages/wonder-stuff-core/dist/browser/es/index.js 1.87 kB
packages/wonder-stuff-sentry/dist/browser/es/index.js 1.66 kB

compressed-size-action

Copy link
Member

@jeresig jeresig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, nice!

@evanchaney
Copy link

👏

Thank you for addressing this.

@somewhatabstract somewhatabstract merged commit 3277b69 into main Feb 15, 2024
8 checks passed
@somewhatabstract somewhatabstract deleted the fixusageoutsidejest branch February 15, 2024 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants