Skip to content

feat(examples): Add context examples #68

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 3 commits into from
May 2, 2018

Conversation

alexkrolick
Copy link
Collaborator

@alexkrolick alexkrolick commented May 2, 2018

What:

  • Add React context examples
  • WIP: Update docs/separate examples in src from actual src tests

Why:

How:

Checklist:

  • Documentation
  • Tests
  • Ready to be merged
  • Added myself to contributors table

Sorry, something went wrong.

how they might appear in your project. (You'll see in the tests that we can
`import {render} from 'react-testing-library'`).

Another thing that we do for the tests is we have a `setup-test-env.js` file in
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Could this be made a bit more obvious by putting it in jest.setup.js or something more similar to how Jest is typically configured?

Copy link
Member

Choose a reason for hiding this comment

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

I've never heard of jest.setup.js before. I'm not sure how much more obvious that is. Though I did consider just adding import 'jest-dom/extend-expect' in every file that needs the extensions to make it more obvious. That's probably the best idea. I'll do that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually it's fine as-is. I think maybe long-term the examples should drop the dependency on kcd-scripts to show a more direct Jest config, but that can be done later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nvm about jest.setup.js - it was manually referenced in my jest config, not automatic.

Copy link
Member

Choose a reason for hiding this comment

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

I think that we need to have an example repo (somewhere else) that shows a good setup. Maybe one that uses create-react-app as well. We could just link to those in the examples.

setupTestFrameworkScriptFile: require.resolve('../other/setup-test-env'),
moduleNameMapper: {
// this is just here so our examples look like they would in a real project
'react-testing-library': require.resolve('../src'),
Copy link
Collaborator Author

@alexkrolick alexkrolick May 2, 2018

Choose a reason for hiding this comment

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

👍 this is cool

@kentcdodds
Copy link
Member

Whelp, I'm not sure what's up with codecov, but this is good to go!

@kentcdodds kentcdodds merged commit c61de92 into testing-library:master May 2, 2018
@alexkrolick alexkrolick deleted the feature/context branch May 2, 2018 20:55
@kentcdodds
Copy link
Member

🎉 This PR is included in version 2.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@kentcdodds
Copy link
Member

Haha, whoops, this probably didn't need to be released 😅 Oh well.

julienw pushed a commit to julienw/react-testing-library that referenced this pull request Dec 20, 2018
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.

None yet

2 participants