diff --git a/README.md b/README.md index b49eaa9..4730c0e 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ You'll also need to: ## Installation: ```bash -npm install --save-dev jest-axe +npm install --save-dev jest jest-axe jest-environment-jsdom ``` [TypeScript](https://www.typescriptlang.org/) users can install the community maintained types package: @@ -30,6 +30,9 @@ npm install --save-dev @types/jest-axe ## Usage: ```javascript +/** + * @jest-environment jsdom + */ const { axe, toHaveNoViolations } = require('jest-axe') expect.extend(toHaveNoViolations) diff --git a/__tests__/__snapshots__/index.test.js.snap b/__tests__/__snapshots__/index.test.js.snap index cb776f0..cdb63a2 100644 --- a/__tests__/__snapshots__/index.test.js.snap +++ b/__tests__/__snapshots__/index.test.js.snap @@ -5,18 +5,18 @@ exports[`jest-axe readme first readme example should demonstrate this matcher\`s Expected the HTML found at $('img') to have no violations: - + Received: -\\"Images must have alternate text (image-alt)\\" +"Images must have alternate text (image-alt)" Fix any of the following: Element does not have an alt attribute aria-label attribute does not exist or is empty aria-labelledby attribute does not exist, references elements that do not exist or references elements that are empty Element has no title attribute - Element's default semantics were not overridden with role=\\"none\\" or role=\\"presentation\\" + Element's default semantics were not overridden with role="none" or role="presentation" You can find more information on this issue here: https://dequeuniversity.com/rules/axe/4.4/image-alt?application=axeAPI @@ -25,11 +25,11 @@ https://dequeuniversity.com/rules/axe/4.4/image-alt?application=axeAPI Expected the HTML found at $('img') to have no violations: - + Received: -\\"All page content should be contained by landmarks (region)\\" +"All page content should be contained by landmarks (region)" Fix any of the following: Some page content is not contained by landmarks @@ -43,19 +43,19 @@ exports[`jest-axe toHaveNoViolations returns correctly formatted message when vi Expected the HTML found at $('body > img') to have no violations: - + Received: -\\"Images must have alternate text (image-alt)\\" +"Images must have alternate text (image-alt)" Fix any of the following: Element does not have an alt attribute aria-label attribute does not exist or is empty aria-labelledby attribute does not exist, references elements that do not exist or references elements that are empty or not visible Element has no title attribute or the title attribute is empty - Element's default semantics were not overridden with role=\\"presentation\\" - Element's default semantics were not overridden with role=\\"none\\" + Element's default semantics were not overridden with role="presentation" + Element's default semantics were not overridden with role="none" You can find more information on this issue here: https://dequeuniversity.com/rules/axe/2.6/image-alt?application=axeAPI" @@ -64,38 +64,38 @@ https://dequeuniversity.com/rules/axe/2.6/image-alt?application=axeAPI" exports[`jest-axe toHaveNoViolations returns properly formatted text with more complex example 1`] = ` "expect(received).toHaveNoViolations(expected) -Expected the HTML found at $('img[src$=\\"example.com\\"]') to have no violations: +Expected the HTML found at $('img[src$="example.com"]') to have no violations: - + Received: -\\"Images must have alternate text (image-alt)\\" +"Images must have alternate text (image-alt)" Fix any of the following: Element does not have an alt attribute aria-label attribute does not exist or is empty aria-labelledby attribute does not exist, references elements that do not exist or references elements that are empty Element has no title attribute - Element's default semantics were not overridden with role=\\"none\\" or role=\\"presentation\\" + Element's default semantics were not overridden with role="none" or role="presentation" You can find more information on this issue here: https://dequeuniversity.com/rules/axe/4.4/image-alt?application=axeAPI -Expected the HTML found at $('img[src=\\"http://example.com/2\\"]') to have no violations: +Expected the HTML found at $('img[src="http://example.com/2"]') to have no violations: - + Received: -\\"Images must have alternate text (image-alt)\\" +"Images must have alternate text (image-alt)" Fix any of the following: Element does not have an alt attribute aria-label attribute does not exist or is empty aria-labelledby attribute does not exist, references elements that do not exist or references elements that are empty Element has no title attribute - Element's default semantics were not overridden with role=\\"none\\" or role=\\"presentation\\" + Element's default semantics were not overridden with role="none" or role="presentation" You can find more information on this issue here: https://dequeuniversity.com/rules/axe/4.4/image-alt?application=axeAPI @@ -104,11 +104,11 @@ https://dequeuniversity.com/rules/axe/4.4/image-alt?application=axeAPI Expected the HTML found at $('input') to have no violations: - + Received: -\\"Form elements must have labels (label)\\" +"Form elements must have labels (label)" Fix any of the following: Form element does not have an implicit (wrapped)