Skip to content

Commit

Permalink
*fix renderAndCheckA11Y axe options
Browse files Browse the repository at this point in the history
  • Loading branch information
Sodik committed Nov 7, 2024
1 parent 0df5ae4 commit ab10244
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
15 changes: 0 additions & 15 deletions packages/test-helpers/src/axe.ts

This file was deleted.

18 changes: 15 additions & 3 deletions packages/test-helpers/src/enzyme.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import { MountRendererProps, mount as mountEnzyme, ReactWrapper } from 'enzyme'
import { axe, toHaveNoViolations } from 'jest-axe'
import { axe, JestAxe, toHaveNoViolations } from 'jest-axe'
import { ReactElement } from 'react'
import { act } from 'react-dom/test-utils'

import { axeDefaultOptions, AxeOptions } from './axe'

expect.extend(toHaveNoViolations)

type AxeOptions = Parameters<JestAxe>[1]
export const axeDefaultOptions: AxeOptions = {
rules: {
// We are testing small units. They might not contain landmarks
region: {
enabled: false,
},
// We are using chrome-off for SelectField
'autocomplete-valid': { enabled: false },
// TODO: Fix later
'aria-tooltip-name': { enabled: false },
},
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
let getAxeNodeDefault: (wrapper: ReactWrapper<any>) => Element = () => document.body
/**
Expand Down
1 change: 0 additions & 1 deletion packages/test-helpers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ export * from './form'
export * from './hooks'
export * from './time'
export * from './utils'
export * from './axe'
export * from './render'
18 changes: 15 additions & 3 deletions packages/test-helpers/src/render.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import { ReactElement } from 'react'
import { render, RenderResult } from '@testing-library/react'
import { axe, toHaveNoViolations } from 'jest-axe'

import { axeDefaultOptions, AxeOptions } from './axe'
import { axe, JestAxe, toHaveNoViolations } from 'jest-axe'

expect.extend(toHaveNoViolations)

type AxeOptions = Parameters<JestAxe>[1]
const axeDefaultOptions: AxeOptions = {
rules: {
// We are testing small units. They might not contain landmarks
region: {
enabled: false,
},
// We are using chrome-off for SelectField
'autocomplete-valid': { enabled: false },
// TODO: Fix later
'aria-tooltip-name': { enabled: false },
},
}

export interface RenderAndCheckA11YOptions {
axeOptions?: AxeOptions
}
Expand Down

0 comments on commit ab10244

Please sign in to comment.