-
Notifications
You must be signed in to change notification settings - Fork 1
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
Setup do Jest e react testing library #37
Conversation
jest.config.ts
Outdated
// All imported modules in your tests should be mocked automatically | ||
// automock: false, | ||
|
||
// Stop running tests after `n` failures | ||
// bail: 0, | ||
|
||
// The directory where Jest should store its cached dependency information | ||
// cacheDirectory: "/private/var/folders/fq/p2wmckfx0w79syz_2b533m9r0000gn/T/jest_dx", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vale a pena deixar documentadas essas opções que não usamos?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vou remover também, acabei me esquecendo
package.json
Outdated
@@ -15,8 +15,12 @@ | |||
"@storybook/react": "^7.0.26", | |||
"@storybook/react-webpack5": "^7.0.26", | |||
"@storybook/testing-library": "^0.0.14-next.2", | |||
"@types/react": "^18.2.14", | |||
"@testing-library/react": "^14.2.0", | |||
"@testing-library/react-native": "^12.4.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vale a pena adicionar enquanto ainda não usarmos o RN no DS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vou remover
"path": "^0.12.7", | ||
"prop-types": "^15.8.1", | ||
"react": "^18.1.0", | ||
"react-dom": "^18.1.0", | ||
"react-test-renderer": "^18.2.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Qual a motivação de adicionar o react-test-renderer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Foi seguindo a instalação do jest sem create-react-app: https://jestjs.io/docs/tutorial-react#setup-without-create-react-app
Contexto
Percebemos que seria interessante escrevermos testes para o DarkModeEnabledContext. Esse PR faz o setup do Jest e da react testing library no DS.
Mudanças
Fora as adições, precisei ajustar os @types do react, para resolver um conflito com os tipos da react testing library. Segui o que encontrei commitado nessa issue: testing-library/react-testing-library#1184
Como testar
__tests__/
, e rode o comandoyarn test
.