Skip to content

docs: use "msw" for API mocking in examples #697

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

Merged
merged 1 commit into from
Jun 5, 2020

Conversation

kettanaito
Copy link
Contributor

What:

Uses msw library for API mocking in the test suite example in README.

Why:

These changes are implemented similar to the React Example from the Testing Library documentation.

How:

  • Initial request handler via setupServer
  • Per-test setup handler via server.use(), allowing to test an error scenario

Checklist:

  • Documentation added to the
    docs site
  • Tests (not applicable)
  • Typescript definitions updated (not applicable)
  • Ready to be merged

@kettanaito
Copy link
Contributor Author

I've also split the two code blocks, assuming there's been a typo and they were merged together by mistake (they showcase two different files). Please let me know if that was intentional, I'll revert the change. Thanks!

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 5, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 2a282e4:

Sandbox Source
nice-dijkstra-zrvl7 Configuration
hidden-wind-b9hll Configuration

@codecov
Copy link

codecov bot commented Jun 5, 2020

Codecov Report

Merging #697 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #697   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines          100       100           
  Branches        16        16           
=========================================
  Hits           100       100           

Continue to review full report at Codecov.

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

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Awesome 👍

@kentcdodds kentcdodds merged commit 26b6c46 into testing-library:master Jun 5, 2020
@kentcdodds
Copy link
Member

@all-contributors please add @kettanaito for docs

@allcontributors
Copy link
Contributor

@kentcdodds

I've put up a pull request to add @kettanaito! 🎉

@kentcdodds
Copy link
Member

🎉 This PR is included in version 10.2.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@kettanaito kettanaito deleted the api-mocks-msw branch June 5, 2020 19:42
@kettanaito
Copy link
Contributor Author

@kentcdodds, thanks for the review! Honored to be a part of this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants