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 test #38

Merged
merged 4 commits into from May 17, 2022
Merged

setup test #38

merged 4 commits into from May 17, 2022

Conversation

KaterinaKorneeeva
Copy link
Contributor

No description provided.

package.json Outdated
Comment on lines 50 to 60
"@testing-library/react": "^13.2.0",
"@types/jest": "^27.5.1",
"express": "^4.18.0",
"express-history-api-fallback": "^2.2.1",
"jest-environment-jsdom": "^28.1.0",
"jest-snapshot": "^28.1.0",
"react": "18.0.0",
"react-dom": "18.0.0",
"react-router-dom": "6.3.0",
"styled-components": "5.3.5"
"styled-components": "5.3.5",
"ts-jest": "^28.0.2"
Copy link
Contributor

Choose a reason for hiding this comment

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

Все, связанное с тестами можно перенести в devDependencies

});
it('should render label', () => {
const text = 'Button';
const button = render(
Copy link
Contributor

Choose a reason for hiding this comment

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

Чтобы каждый раз не оборачивать компонент в провайдер, можно завести функцию customRender:

function customRender(children) {
  return render(
    <ThemeProvider theme={baseTheme}>
      {children}
    </ThemeProvider>
  );
}

И тогда вызывать ее в тестах вот так

customRender(<Button>{text}</Button>);

Корнеева Екатерина added 2 commits May 17, 2022 16:03
const Avatar = styled.div.attrs((props: AvatarProps) => ({
backgroundImage: props.backgroundImage,
size: props.size,
role: 'avatar',
Copy link
Contributor

Choose a reason for hiding this comment

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

Атрибут role вообще нужен для обеспечения доступности — чтобы скринридеры могли понять например, что на элемент можно нажать. И у него есть определенный список значений — https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques#roles

В данном случае думаю лучше всего подойдет button, потому что по элементу можно кликнуть

@KaterinaKorneeeva KaterinaKorneeeva merged commit f5d5798 into main May 17, 2022
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

3 participants