Testing



import {render, screen, waitFor} from '@testing-library/react'  

Jest


Use Create-React-App
This uses both Jest and React-Testing-Library


react-scripts

automatically sets up our server to watch for changes.
If the test file is modified the server automatically compiles and reruns the test(s)


test('description', () => {  
  render(<App />);
  const getElement = screen.getByText(/learn react/i);
  expect(getElement).toBeInTheDocument();
});

describe(my test block',() => {  
   test('isTrue', () => {
     render(<App />);
     expect(true).toBe(true);
   });
});

This will run all the tests

npm run test 




© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext