Skip to content

Latest commit

 

History

History
42 lines (28 loc) · 955 Bytes

README.md

File metadata and controls

42 lines (28 loc) · 955 Bytes

alsatian-react-testing-library

This package provides helpers for testing React components in Typescript with React Testing Library and Alsatian.

Installation

npm i alsatian-react-testing-library

Usage

import { Test, TestFixture } from "alsatian";
import { ExpectElement } from "alsatian-react-testing-library";
import { render } from "@testing-library/react";

import { MyComponent } from "./MyComponent";

configureJSDOM(); // This is important!

@TestFixture("MyComponent")
export class MyComponentTests {

    @Test("should render component")
    public shouldRenderComponent() {

        const wrapper = render(<MyComponent />);

        ExpectElement(wrapper).toMatchElement(
            <div>
                My components body.
            </div>
        );
    }

}

License

Made with 💖 by NewOrbit in Oxfordshire, and licensed under the MIT Licence