1.3.0 • Published 7 days ago

@volkovlabs/jest-selectors v1.3.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
7 days ago

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.

1.3.0

7 days ago

1.2.0

10 months ago

1.1.0

10 months ago

1.0.0

10 months ago