Skip to content

Instantly share code, notes, and snippets.

Created August 4, 2023 10:02
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
You can add this code in the App.test.js. It is not necessary to create another test file.
test('performs division', () => {
render(<App />);
const inputElement = screen.getByRole('textbox');
// Check the value of the textbox (initially it should be an empty string)
// Simulate clicking the buttons to enter the expression "2+3" into the calculator'1'));
expect( inputElement.value ).toBe("1")'0'));
expect( inputElement.value ).toBe("10")
// expect(inputElement.textContent).toBe(' 2');'/'));
// Simulate clicking the "=" button'='));
//select the 'result' div and check if it's value is 5
const resultElement = screen.getByTestId('result');
expect(resultElement.textContent).toBe('5');//or expect(resultElement).toHaveTextContent('5')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment