My test fails for some weird reason.
Below is the file that contains the whole code, I am not sure why it fails, even when I used different matchers and attributes that I expect to work like “getByPlaceholderText”, it stills fail with the same error.
sum.test.js
/* eslint-disable no-undef */
import React from 'react';
import { render, screen } from '@testing-library/react';
function InputComponent() {
return <input type="text" name="userName" />;
}
test('renders input with aria-label', () => {
render(<InputComponent />);
const inputElement = screen.getByRole('textbox');
expect(inputElement).toBeInTheDocument();
});
The error in the console says,
FAIL sum.test.js [ sum.test.js ]
Error: Expression expected
❯ getRollupError ../../../.nvm/versions/node/v20.5.0/lib/node_modules/vitest/node_modules/rollup/dist/es/shared/parseAst.js:396:41
Test Files 1 failed (1)
Tests no tests
Start at 15:08:31
Duration 0ms