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

refactor(format): make the error messages more readable #13

Merged
merged 48 commits into from
Jun 2, 2020

Conversation

mohanraj-r
Copy link
Contributor

@mohanraj-r mohanraj-r commented May 29, 2020

Refactor formatter to

  • add number of total issues to output
  • sort a11y issues by impact
  • rearrange to bring rule-id to front
  • add unicode chars to mark the issue boundary and help url clearly
  • remove ?application=axeAPI referral from Help URLs
  • based on custom error object

Primary changes in

Other changes:

  • rename registerA11yMatchers to registerSa11yMatcher
  • add .circleci/config.yml

After this PR is merged, I will publish the packages to npm.

Before

  expect(received)toBeAccessible: expected document to have no accessibility violations but found
 following issues:

     Error: Page must have means to bypass repeated blocks (bypass): html
      - More info: https://dequeuniversity.com/rules/axe/3.5/bypass?application=axeAPI

    Documents must have <title> element to aid in navigation (document-title): html
      - More info: https://dequeuniversity.com/rules/axe/3.5/document-title?application=axeAPI

    Document must have one main landmark (landmark-one-main): html
      - More info: https://dequeuniversity.com/rules/axe/3.5/landmark-one-main?application=axeAPI

    Links must have discernible text (link-name): a
      - More info: https://dequeuniversity.com/rules/axe/3.5/link-name?application=axeAPI

    Page must contain a level-one heading (page-has-heading-one): html
      - More info: https://dequeuniversity.com/rules/axe/3.5/page-has-heading-one?application=axeAPI(expected)

After

 expect(5 issues)toBeAccessible: expected document to have no accessibility violations but found 5 issues:

     "β­• (bypass) Page must have means to bypass repeated blocks: html"
        πŸ”— Help URL: https://dequeuniversity.com/rules/axe/3.5/bypass

    "β­• (document-title) Documents must have <title> element to aid in navigation: html"
        πŸ”— Help URL: https://dequeuniversity.com/rules/axe/3.5/document-title

    "β­• (link-name) Links must have discernible text: a"
        πŸ”— Help URL: https://dequeuniversity.com/rules/axe/3.5/link-name

    "β­• (landmark-one-main) Document must have one main landmark: html"
        πŸ”— Help URL: https://dequeuniversity.com/rules/axe/3.5/landmark-one-main

    "β­• (page-has-heading-one) Page must contain a level-one heading: html"
        πŸ”— Help URL: https://dequeuniversity.com/rules/axe/3.5/page-has-heading-one(0 issues)

Screenshot:
image

Mohan Raj Rajamanickam and others added 16 commits May 13, 2020 20:14
to make the badge in readme follow common convention
as it doesn't seem to be affecting the tests??
jsdom as direct dependency doesn't seem to be needed anymore
Reformat a11y error msg to include total num of issues, unicode chars to represent a11y issue & help
url, rearrange error msg fields, add jest matcher helper to include more info about received vs
actual
docs(rules): add readme information with details about the rules included in each pre-config ruleset
@mohanraj-r mohanraj-r requested a review from a team May 29, 2020 02:31
@mohanraj-r mohanraj-r self-assigned this May 29, 2020
@mohanraj-r
Copy link
Contributor Author

Looks like I missed some lint errors. Although the pre-commit hook ran the linter on changes, looks the whole picture got missed. Working on fixing them.
Also added lint check to pre-push git hook to avoid this in future.

@mohanraj-r mohanraj-r changed the title Refactor formatter to make the error messages more readable refactor(format): make the error messages more readable May 29, 2020
@mohanraj-r
Copy link
Contributor Author

Looks like I missed some lint errors. Although the pre-commit hook ran the linter on changes, looks the whole picture got missed. Working on fixing them.
Also added lint check to pre-push git hook to avoid this in future.

Looks like the issue was a last minute update to dependencies I did after I created the PR 🀦 - which caused bunch of eslint packages to be updated - which seems to have added/changed some checks. Reverted those updates for now which fixed those errors - will investigate the eslint updates in next PR.

But now the build is failing with Jest snapshot errors saying they are not up-to-date - but the updated snapshots have been checked in and the tests pass locally after a clean build. Even checked out the branch to a diff clean location in my machine and tried out the CI commands - no issues πŸ˜•

@trevor-bliss Have you encountered this issue with Jest snapshots in CI ?

@trevor-bliss
Copy link

@mohanraj-r I'm not exactly sure what's going on here... My only guess is it's something to do with the unicode characters. Maybe Jest is getting confused with the β­•symbol.

@trevor-bliss
Copy link

To test maybe try stripping the β­•symbol and any other special characters before taking the snapshot?

Only other thing I can think of right now is the CI might be doing some weird caching? I'm not too familiar with github CI.

const helpURL = violation.helpUrl.split('?')[0];
return (
// TODO: Create a formatter specifically for Jest using printReceived etc?
printReceived(`β­• (${violation.id}) ${violation.help}: ${selectors}`) +

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels a little weird to me to call this Jest matcher API here. I would think the Jest specific APIs would only be called in the matcher package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, was thinking similar. Will try to refactor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trevor-bliss refactored to remove the jest specific matchers to be passed from jest package

Mohan Raj Rajamanickam and others added 27 commits May 29, 2020 15:36
move func to get num of issues from matcher to format
This reverts commit dfc39c1.

# Conflicts:
#	packages/assert/__tests__/__snapshots__/assert.test.ts.snap
#	packages/format/__tests__/__snapshots__/format.test.ts.snap
#	packages/jest/__tests__/__snapshots__/matcher.test.ts.snap
This reverts commit 72c5e28.

# Conflicts:
#	packages/jest/__tests__/__snapshots__/matcher.test.ts.snap
revert workarounds tested for #14
for consistency with build step
check if the snapshot errors could be related to OS #14
to use docker image tag and new syntax
as there is only 1 matcher and adding sa11y name to make it easily identifiable
Copy link

@trevor-bliss trevor-bliss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@mohanraj-r mohanraj-r merged commit 80a5d05 into master Jun 2, 2020
@mohanraj-r mohanraj-r deleted the refactor_formatter branch June 2, 2020 23:07
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.

None yet

3 participants