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

Setup do Jest e react testing library #37

Merged
merged 2 commits into from
Feb 1, 2024
Merged

Setup do Jest e react testing library #37

merged 2 commits into from
Feb 1, 2024

Conversation

leocpadua7
Copy link
Contributor

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

  • Crie qualquer teste em uma pasta __tests__/, e rode o comando yarn test.

@leocpadua7 leocpadua7 added the enhancement New feature or request label Feb 1, 2024
jest.config.ts Outdated
Comment on lines 9 to 16
// 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",
Copy link
Contributor

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?

Copy link
Contributor Author

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

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?

Copy link
Contributor Author

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

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?

Copy link
Contributor Author

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

@leocpadua7 leocpadua7 merged commit e1ef1e1 into master Feb 1, 2024
1 check passed
@leocpadua7 leocpadua7 deleted the add-jest branch February 1, 2024 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants