toHaveNoViolations does not exist on type Matchers<any> typescript

See original GitHub issue

I get the following error when trying to get this working with ts-jest:

TypeScript diagnostics (customize using `[jest-config].globals.ts-jest.diagnostics` option):
    src/components/PriceBreakdown/components/ChargesList/ChargesList.test.tsx:124:19 - error TS2339: Property 'toHaveNoViolations' does not exist on type 'Matchers<any>'.

I am following the documentation correctly so I was just wondering if there is any documentation around using this with typescript.

example of how I am using it:

import { axe, toHaveNoViolations } from "jest-axe";

expect.extend(toHaveNoViolations);

it("should be accessible", async () => {
         // wrap is just a react component
	const { container } = wrap([fee1, fee2, fee3], "Some text", true);
	const results = await axe(container);
	expect(results).toHaveNoViolations();
});

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
ghostcommented, Oct 22, 2019

I had the same problem. I fixed it with npm i -D @types/jest-axe

2reactions
NickColleycommented, Oct 30, 2019

I wonder if we should add @hernandezbb 's advice to the README?

Read more comments on GitHub >

github_iconTop Results From Across the Web

toHaveNoViolations does not exist on type Matchers<any ...
I get the following error when trying to get this working with ts-jest: TypeScript diagnostics (customize using `[jest-config].globals.ts-jest.diagnostics` ...
Read more >
reactjs - Property 'toBeInTheDocument' does not exist on type ...
Property 'toBeInTheDocument' does not exist on type 'JestMatchers<HTMLElement>'. which leads to Cannot use import statement outside a module ...
Read more >
jest-axe - npm
Start using jest-axe in your project by running `npm i jest-axe`. There are 59 other projects in the npm registry using jest-axe.
Read more >
Just an FYI. You can add the axe toHaveNoViolations matcher ...
Just an FYI. You can add the axe toHaveNoViolations matcher globally so you don't have to import it in your tests.
Read more >
TS2339: Property 'toHaveBeenCalledWith' does not exist on ...
TS2339: Property 'toHaveBeenCalledWith' does not exist on type 'Assertion'. When doing Angular tests from WebStorm, I keep getting these error notifications ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found