Skip to content

Commit 73d3a8c

Browse files
committed
fix getByRole is not a function error when running tests
1 parent cc87781 commit 73d3a8c

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/components/Alert/Alert.test.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ describe('Alert component', () => {
1313
test('applies success styles when message contains "success"', () => {
1414
render(<Alert onClick={() => {}} message="Success: Operation completed" />);
1515

16-
const alertDiv = screen
17-
.getByText(/success: operation completed/i)
18-
.getByRole('alert');
16+
const alertDiv = screen.getByRole('alert');
1917

2018
expect(alertDiv).toHaveClass(
2119
'bg-teal-100',
@@ -26,9 +24,7 @@ describe('Alert component', () => {
2624
test('applies error styles when message does not contain "success"', () => {
2725
render(<Alert onClick={() => {}} message="Error: Something went wrong" />);
2826

29-
const alertDiv = screen
30-
.getByText(/error: something went wrong/i)
31-
.getByRole('alert');
27+
const alertDiv = screen.getByRole('alert');
3228

3329
expect(alertDiv).toHaveClass(
3430
'bg-red-100',

0 commit comments

Comments
 (0)