Skip to content

Conversation

iqbal125
Copy link
Contributor

simple test example to test if a child component can update the context state.

simple test example to test if a child component can update the context state.
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.

This looks fine to me, but we should add jsx to the codefences so we get syntax highlighting:

```js code... ```
@alexkrolick
Copy link
Collaborator

One comment - naming the inner component TestComponent could make people think that is a special for component just for the test instead of part of the App. Can we change that and add a note along the lines of:

The basic idea is to test your components as they are used. Instead of testing the context-providing component separately, your main focus should be testing that the features connected to the context work correctly.

Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

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

Some nitpicks:

  • use flat folder structure (nesting is not necessary for this example)
  • consistent import from react (sometimes React.createContext, sometimes import { useContext } from 'react'
iqbal125 added 2 commits July 1, 2019 13:40
removed semi colons
changed child component name and added brief description of test.
@iqbal125
Copy link
Contributor Author

iqbal125 commented Jul 1, 2019

@kentcdodds @eps1lon @alexkrolick @afontcu Made changes based on feedback let me know what you think.

@iqbal125
Copy link
Contributor Author

@afontcu Made changes based on feedback let me know what you think.

iqbal125 and others added 4 commits July 24, 2019 11:35
@iqbal125
Copy link
Contributor Author

@afontcu was able to make the changes let me know what you think.

Copy link
Member

@afontcu afontcu left a comment

Choose a reason for hiding this comment

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

Looks great from here, thank you very much for this 😄

iqbal125 and others added 3 commits July 28, 2019 11:03
Co-Authored-By: Adrià Fontcuberta <afontcu@gmail.com>
Co-Authored-By: Adrià Fontcuberta <afontcu@gmail.com>
@afontcu
Copy link
Member

afontcu commented Aug 10, 2019

I've cleaned up the file a bit (whitespacing, naming, etc), but I'd love someone else to check that the actual example test makes sense (from a React/useContext point of view). Not sure if using it with useState makes the example a bit cumbersome.

Your call! :)

Copy link
Collaborator

@alexkrolick alexkrolick left a comment

Choose a reason for hiding this comment

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

It would be good to link this page to the wrapper docs to show how to deal with Context providers when you aren't rendering a whole app. We also need to add an entry in the navigation tree for this page.

@alexkrolick alexkrolick added hacktoberfest 🎃 help wanted 👋 Extra attention is needed labels Oct 1, 2020
@eps1lon eps1lon closed this May 5, 2021
@eps1lon eps1lon deleted the branch testing-library:master May 5, 2021 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted 👋 Extra attention is needed

6 participants