React Browser Tests
  • Home
  • Components
    • Test Container
    • Test
    • Test Group
    • Single Test Container Overview
    • Multiple Test Container Overview
    • Multiple Page Overview
    • Sidebar Layout
  • Helper Functions
  • Run in a Terminal
  • Tests

<TestGroup>

Groups multiple <Test> components together. <Test> components can be used without a <TestGroup> parent.

Currently, the main uses for this component are:

  1. Providing before and after functions for a group of tests.
  2. Organizing the tests results shown in a terminal.
  3. The overview components can show stats for test groups.

Example in a NextJS page:

import { Test, TestContainer, TestGroup, expect } from "react-browser-tests";

export default function TestPage() {
  return (
    <TestContainer>
      <TestGroup title="Math tests">
        <Test title="Expect 1 + 1 to equal 2." fn={() => {
          expect(1 + 1).to.equal(2);
        }} />
      </TestGroup>
    </TestContainer>
  );
}

If we navigate to that page, we'll see the following:

Expect 1 + 1 to equal 2.

Props

title

Test group title.

beforeEach?

Function that runs before each test in the test group.

afterEach?

Function that runs after each test in the test group.

beforeAll?

Function that runs before all tests in the test group.

afterAll?

Function that runs after all tests in the test group.

HTMLDivElement props

Supports standard HTMLDivElement props. For example: className, style, etc.