Skip to content
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

chore(ui-scripts,ui-test-utils): move test utils #1308

Merged
merged 1 commit into from
Oct 6, 2023

Conversation

balzss
Copy link
Contributor

@balzss balzss commented Oct 5, 2023

INSTUI-3875

test plan:

  • pick a random component that uses generateA11yTests in its tests
  • comment out everything else in that test file (besides the generateA11yTests part) and run that test with npm run test -- --path packages/ui-component-name (with the actual path to that component)
  • note down how many tests were run (should be around 1-4)
  • next to that components __tests__ folder create a __new-tests__ folder
  • create a test file named ComponentName.test.tsx (replace ComponentName with the actual name of the component)
  • add the following code to that test:
import { render } from '@testing-library/react'

import { runAxeCheck } from '@instructure/ui-axe-check'
import { ComponentName } from '../index'
import ComponentNameExamples from '../__examples__/ComponentName.examples'
// eslint-disable-next-line no-restricted-imports
import { generateA11yTests } from '@instructure/ui-scripts/lib/test/generateA11yTests'

describe('<Breadcrumb />', () => {
  const generatedComponents = generateA11yTests(
    ComponentName,
    ComponentNameExamples
  )
  for (const component of generatedComponents) {
    it(component.description, async () => {
      const { container } = render(component.content)
      const axeCheck = await runAxeCheck(container)
      expect(axeCheck).toBe(true)
    })
  }
})
  • run the new test with npm run test:new -- packages/ui-component-name
  • the number of tests in the new test should match the number from the old tests

@balzss balzss self-assigned this Oct 5, 2023
@github-actions
Copy link

github-actions bot commented Oct 5, 2023

Preview URL: https://1308--preview-instui.netlify.app

@balzss balzss changed the title WIP(ui-billboard,ui-breadcrumb,ui-scripts,ui-test-utils): move test utils chore(ui-scripts,ui-test-utils): move test utils Oct 6, 2023
@balzss balzss requested review from joyenjoyer and HerrTopi October 6, 2023 10:12
@balzss balzss marked this pull request as ready for review October 6, 2023 10:12
@balzss balzss merged commit 28c347a into master Oct 6, 2023
4 checks passed
@balzss balzss deleted the chore/move-test-utils branch October 6, 2023 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants