Skip to content

Migrate Label.test.tsx from Jest to Vitest #6301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/react/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module.exports = {
'<rootDir>/src/Flash/',
'<rootDir>/src/FormControl/__tests__/FormControl.Validation.test.tsx',
'<rootDir>/src/InlineMessage/',
'<rootDir>/src/Label/',
'<rootDir>/src/NavList/',
'<rootDir>/src/Octicon/',
'<rootDir>/src/Pagehead/',
Expand Down
17 changes: 4 additions & 13 deletions packages/react/src/Label/Label.test.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import {describe, expect, it} from 'vitest'
import {render} from '@testing-library/react'
import axe from 'axe-core'
import type {LabelColorOptions} from '../Label'
import Label, {variants} from '../Label'
import Label from '../Label'

describe('Label', () => {
it('should support `className` on the outermost element', () => {
const Element = () => <Label className={'test-class-name'} />
expect(render(<Element />).container.firstChild).toHaveClass('test-class-name')
})
it('renders text node child', () => {
const container = render(<Label>Default</Label>)
const label = container.baseElement
expect(label.textContent).toEqual('Default')
const rendered = render(<Label>Default</Label>)
expect(rendered.container.textContent).toEqual('Default')
})
it('default size is rendered as "small"', () => {
const {getByText} = render(<Label>Default</Label>)
Expand All @@ -24,11 +22,4 @@ describe('Label', () => {

expect(getByText('Default')).toHaveAttribute('data-variant', 'default')
})
it('should have no axe violations', async () => {
for (const variant in variants) {
const {container} = render(<Label variant={variant as LabelColorOptions}>Default</Label>)
const results = await axe.run(container)
expect(results).toHaveNoViolations()
}
})
})
1 change: 1 addition & 0 deletions packages/react/vitest.config.browser.mts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default defineConfig({
'src/Flash/**/*.test.?(c|m)[jt]s?(x)',
'src/FormControl/__tests__/FormControl.Validation.test.tsx',
'src/InlineMessage/**/*.test.?(c|m)[jt]s?(x)',
'src/Label/**/*.test.?(c|m)[jt]s?(x)',
'src/NavList/**/*.test.?(c|m)[jt]s?(x)',
'src/Octicon/**/*.test.?(c|m)[jt]s?(x)',
'src/Pagehead/**/*.test.?(c|m)[jt]s?(x)',
Expand Down
Loading