1.0.0 • Published 5 years ago

react-jest-test-utils v1.0.0

Weekly downloads
4
License
ISC
Repository
github
Last release
5 years ago

Generate Get Element by Data Attribute

npm version

This package aims to prevent you from having to write same function over and over again.

Instead of writing

document.querySelector("[data-testid=my-first-button");
document.querySelector("[data-testid=my-second-button");
document.querySelector("[data-testid=my-third-button");

each time you would like to access an element from a testid, this package allow you to write

import { generateGetElementByDataAttribute } from "generate-get-element-by-data-attribute";

const getElementByTestId = generateGetElementByDataAttribute("testid");

getElementByTestId(document.body, "first-button");
getElementByTestId(document.body, "second-button");
getElementByTestId(document.body, "third-button");

Helpful for writing a lot of Jest tests.

Type definitons are provided!

1.0.0

5 years ago