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.

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);

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.

Leave a Reply