Skip to content

Commit bda6d76

Browse files
authored
fix: jest config & screen usage (gitify-app#977)
1 parent f91e443 commit bda6d76

19 files changed

+251
-232
lines changed

jest.config.js renamed to jest.config.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
const config = {
2-
preset: 'ts-jest/presets/js-with-ts',
1+
import type { Config } from 'jest';
2+
3+
const config: Config = {
4+
preset: 'ts-jest',
35
setupFiles: ['<rootDir>/src/__helpers__/setupEnvVars.js'],
46
testEnvironment: 'jsdom',
57
collectCoverage: true,
@@ -13,6 +15,7 @@ const config = {
1315
// via https://github.com/axios/axios/issues/5101#issuecomment-1276572468
1416
'^axios$': require.resolve('axios'),
1517
},
18+
modulePathIgnorePatterns: ['<rootDir>/build', '<rootDir>/node_modules'],
1619
};
1720

1821
module.exports = config;

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
"style-loader": "3.3.4",
150150
"tailwindcss": "3.4.3",
151151
"ts-jest": "29.1.2",
152+
"ts-node": "^10.9.2",
152153
"webpack": "5.91.0",
153154
"webpack-cli": "5.1.4",
154155
"webpack-merge": "5.10.0"

pnpm-lock.yaml

+106-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Logo.test.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { fireEvent, render } from '@testing-library/react';
1+
import { fireEvent, render, screen } from '@testing-library/react';
22

33
import * as TestRenderer from 'react-test-renderer';
44

@@ -19,9 +19,9 @@ describe('components/Logo.tsx', () => {
1919

2020
it('should click on the logo', () => {
2121
const onClick = jest.fn();
22-
const { getByRole } = render(<Logo onClick={onClick} />);
22+
render(<Logo onClick={onClick} />);
2323

24-
fireEvent.click(getByRole('logo'));
24+
fireEvent.click(screen.getByLabelText('Gitify Logo'));
2525

2626
expect(onClick).toHaveBeenCalledTimes(1);
2727
});

src/components/Logo.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export const Logo = ({ isDark, onClick, className = '', ...props }: IProps) => (
1717
xmlns="http://www.w3.org/2000/svg"
1818
xmlnsXlink="http://www.w3.org/1999/xlink"
1919
viewBox="0 0 500 500"
20-
role="logo"
20+
role="img"
21+
aria-label="Gitify Logo"
2122
{...props}
2223
>
2324
<defs>

0 commit comments

Comments
 (0)