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

[fei5850.2.hardfail] Add hard fail support to request mocking #2334

Merged
merged 2 commits into from
Oct 2, 2024

Conversation

somewhatabstract
Copy link
Member

@somewhatabstract somewhatabstract commented Oct 1, 2024

Summary:

An oft annoying but sometimes useful feature of Apollo's MockLink is that it will hard fail if a request is made that has not been mocked. This is annoying because it forces folks to provide a mock for every request, even if they don't care about that request. However, it is useful when debugging tests to see why a mock isn't matching as expected or what requests are happening (the KA_LOG_FETCHES is useful for seeing this info too, but less accessible).

This change adds the ability to turn on hard fails for our request mocking system. I have added this using a fluent API so that it is more easily worked into existing uses of this mocking system.

I've also added tests to verify the new functionality, and added some additional commentary to the types for the mocking framework.

Issue: FEI-5850

Test plan:

yarn test
yarn typecheck

@somewhatabstract somewhatabstract self-assigned this Oct 1, 2024
@somewhatabstract somewhatabstract requested review from a team October 1, 2024 18:49
Copy link

changeset-bot bot commented Oct 1, 2024

🦋 Changeset detected

Latest commit: 2fe2866

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

This PR includes changesets to release 2 packages
Name Type
@khanacademy/wonder-blocks-testing-core Minor
@khanacademy/wonder-blocks-testing Minor

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
Copy link
Contributor

khan-actions-bot commented Oct 1, 2024

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .changeset/great-paws-ring.md, __docs__/wonder-blocks-testing/exports.mock-fetch.mdx, __docs__/wonder-blocks-testing/exports.mock-gql-fetch.mdx, packages/wonder-blocks-testing-core/src/index.ts, packages/wonder-blocks-testing-core/src/mock-requester.ts, packages/wonder-blocks-testing-core/src/types.ts, packages/wonder-blocks-testing/src/gql/mock-gql-fetch.ts, packages/wonder-blocks-testing/src/gql/types.ts, packages/wonder-blocks-testing-core/src/__tests__/mock-requester.test.ts, packages/wonder-blocks-testing-core/src/fetch/mock-fetch.ts, packages/wonder-blocks-testing-core/src/fetch/types.ts, packages/wonder-blocks-testing/src/gql/__tests__/mock-gql-fetch.test.tsx

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

Copy link
Contributor

github-actions bot commented Oct 1, 2024

npm Snapshot: Published

🎉 Good news!! We've packaged up the latest commit from this PR (67c6616) and published all packages with changesets to npm.

You can install the packages in webapp by running:

./services/static/dev/tools/deploy_wonder_blocks.js --tag="PR2334"

Packages can also be installed manually by running:

yarn add @khanacademy/wonder-blocks-<package-name>@PR2334

Copy link
Contributor

github-actions bot commented Oct 1, 2024

A new build was pushed to Chromatic! 🚀

https://5e1bf4b385e3fb0020b7073c-izufdnwrxc.chromatic.com/

Chromatic results:

Metric Total
Captured snapshots 370
Tests with visual changes 0
Total stories 495
Inherited (not captured) snapshots [TurboSnap] 0
Tests on the build 370

Copy link
Contributor

github-actions bot commented Oct 1, 2024

Size Change: 0 B

Total Size: 100 kB

ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 3.78 kB
packages/wonder-blocks-banner/dist/es/index.js 1.53 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.61 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 887 B
packages/wonder-blocks-button/dist/es/index.js 4.04 kB
packages/wonder-blocks-cell/dist/es/index.js 2.01 kB
packages/wonder-blocks-clickable/dist/es/index.js 3.06 kB
packages/wonder-blocks-core/dist/es/index.js 3.44 kB
packages/wonder-blocks-data/dist/es/index.js 6.24 kB
packages/wonder-blocks-dropdown/dist/es/index.js 18 kB
packages/wonder-blocks-form/dist/es/index.js 6.18 kB
packages/wonder-blocks-grid/dist/es/index.js 1.36 kB
packages/wonder-blocks-i18n/dist/es/index.js 4.76 kB
packages/wonder-blocks-icon-button/dist/es/index.js 3 kB
packages/wonder-blocks-icon/dist/es/index.js 828 B
packages/wonder-blocks-labeled-field/dist/es/index.js 72 B
packages/wonder-blocks-layout/dist/es/index.js 1.82 kB
packages/wonder-blocks-link/dist/es/index.js 2.28 kB
packages/wonder-blocks-modal/dist/es/index.js 5.36 kB
packages/wonder-blocks-pill/dist/es/index.js 1.65 kB
packages/wonder-blocks-popover/dist/es/index.js 4.87 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.52 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.3 kB
packages/wonder-blocks-switch/dist/es/index.js 1.94 kB
packages/wonder-blocks-testing-core/dist/es/index.js 3.74 kB
packages/wonder-blocks-testing/dist/es/index.js 1.07 kB
packages/wonder-blocks-theming/dist/es/index.js 693 B
packages/wonder-blocks-timing/dist/es/index.js 1.8 kB
packages/wonder-blocks-tokens/dist/es/index.js 2.1 kB
packages/wonder-blocks-toolbar/dist/es/index.js 827 B
packages/wonder-blocks-tooltip/dist/es/index.js 7.08 kB
packages/wonder-blocks-typography/dist/es/index.js 1.23 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.

Great!

Base automatically changed from fei5850.1.friendlyobjectmatching to main October 2, 2024 17:15
@somewhatabstract somewhatabstract merged commit 16565a8 into main Oct 2, 2024
11 checks passed
@somewhatabstract somewhatabstract deleted the fei5850.2.hardfail branch October 2, 2024 17:17
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.

3 participants