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

<TestContainer>

Container of <Test> components. Uses react context to manage the state of the tests.

<Test> components must have a <TestContainer> parent somewhere in the tree.

Example in a NextJS page:

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

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

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

Expect 1 + 1 to equal 2.

Props

beforeEach?

Function that runs before each test in the container.

afterEach?

Function that runs after each test in the container.

beforeAll?

Function that runs before all tests in the container.

afterAll?

Function that runs after all tests in the container.

css?

CSS styles to apply to the container's elements. The default value is a CSS string constant called testContainerStyles, exported from the styles.ts file.

HTMLDivElement props

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