Skip to content

Helpers for testing React in TypeScript with React Testing Library and Alsatian

License

Notifications You must be signed in to change notification settings

NewOrbit/alsatian-react-testing-library

Repository files navigation

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

About

Helpers for testing React in TypeScript with React Testing Library and Alsatian

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •