@volkovlabs/jest-selectors
TypeScript icon, indicating that this package has built-in type declarations

1.5.0 • Public • Published

Jest selectors

Install

npm install --save-dev @volkovlabs/jest-selectors

Example of usage

import { screen } from '@testing-library/react'
import { getJestSelectors } from '@volkovlabs/jest-selectors';

const TestIds = {
  panel: {
    container: 'data-testid panel',
    button: (name: string) => 'panel button ${name}',
  }
}

const getPanelSelectors = getJestSelectors(TestIds.panel);

test('Panel', () => {
  const selectors = getPanelSelectors(screen)

  selectors.container() // screen.getByTestId
  selectors.container(true) // screen.queryByTestId
  selectors.button(false, 'submit') // screen.getByLabelText
  selectors.button(true, 'submit') // screen.queryByLabelText
})

License

Apache License Version 2.0.

Readme

Keywords

Package Sidebar

Install

npm i @volkovlabs/jest-selectors

Weekly Downloads

66

Version

1.5.0

License

Apache-2.0

Unpacked Size

21.2 kB

Total Files

7

Last publish

Collaborators

  • asimonok
  • mikhailvl