Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Whats difference between test suite and test

Just installed fresh new react.

Create new utils.js file in src folder and write this function.

export const sum = (a, b) => {
  return a + b;
};

In App.test.js I add this test.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

test("test sum function", () => {
  expect(sum(4, 6)).toBe(10);
  expect(sum(4, 40)).toBe(44);
});

In App.test.js I have also this default testing code.

test("renders learn react link", () => {
  render(<App />);
  const linkElement = screen.getByText(/learn react/i);
  expect(linkElement).toBeInTheDocument();
});

When I run npm t jest show me

Test suites: 1 passed, 1 total
Tests:       2 passed, 2 total

I’m wondering what’s the difference between test suites and tests? Why test suites show me 1 total, when I have 2 tests?

>Solution :

Test suites contain one or more tests. In this case App.test.js is the test suite. That suite contains two tests, "test sum function" and "renders learn react link". This means you have one test suite with 2 tests.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading