-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: add vitest-axe
& update frontend tests
#3549
Conversation
Removed vultr server and associated DNS entries |
vitest-axe
& update frontend tests
@@ -107,10 +106,10 @@ describe("Pay component - Editor Modal", () => { | |||
expect(getByDisplayValue("myValue")).toBeInTheDocument(); | |||
}); | |||
|
|||
it("allows new values to be added", async () => { | |||
it("allows new values to be added", { timeout: 20000 }, async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rather than a single jest.setTimeout(2000)
at the top of the file, I've gone for per-test timeouts like this as it seems useful/helpful to keep a more specific pulse on which frontend interactions are slow running / easier to work through them & optimise over time?
if preferred, we still have a per-file option of vi.setConfig({ testTimeout: 20000 })
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach works well for me! Easier to come back and revisit a test at a time, than a whole suite at a time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for this - a whole lot covered and tidied up here.
A lot of the linting issues fixed have come from some of my recent PRs, will check what's going on with Husky and try to run git commit
from a standard directory.
Let's merge this to dp/vite
and then fix outstanding issues from there ✅
state.saveToEmail, | ||
state.$public, | ||
]); | ||
const [sessionId, saveToEmail, $public, passport, govUkPayment, flowName] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quite a few Confirmation related changes in this PR - expecting these to go away once dp/vite
has rebased to main
👍
@@ -41,7 +41,7 @@ describe("FileUploadAndLabel - Editor Modal", () => { | |||
expect(screen.getAllByText("File")).toHaveLength(1); | |||
}); | |||
|
|||
it.skip("allows an Editor to add multiple rules", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! Worth us probably checking out all existing skips()
once this vite + vitest migration is done and maybe opening GitHub issues for them.
@@ -107,10 +106,10 @@ describe("Pay component - Editor Modal", () => { | |||
expect(getByDisplayValue("myValue")).toBeInTheDocument(); | |||
}); | |||
|
|||
it("allows new values to be added", async () => { | |||
it("allows new values to be added", { timeout: 20000 }, async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach works well for me! Easier to come back and revisit a test at a time, than a whole suite at a time.
|
||
expect(result).toEqual({ | ||
intersectingConstraints: defaultIntersectingConstraints, | ||
nots: defaultNots, | ||
}); | ||
}); | ||
|
||
// Intentional skip, not handling these edge cases yet! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Helpful comment!
vi.spyOn(window, "location", "get").mockReturnValue( | ||
mockWindowLocationObject, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This might be something we can put in a beforeEach()
(not for this PR, just a reminder to come back and take a look at this!)
Also getting a few linting issues in this file, will flag with @RODO94 tomorrow or open a quick PR here.
// export const axe = configureAxe({ | ||
// rules: { | ||
// // Currently, jest-axe does not correctly evaluate this rule due to an issue with jsdom | ||
// // https://github.com/dequelabs/axe-core/issues/2587 | ||
// // To pass this test, non-decorative MUI icons should always use the 'titleAccess' prop | ||
// "svg-img-alt": { enabled: false }, | ||
// }, | ||
// }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to know we don't need this - if we see an error with titleAccess
again or failing a11y tests we can revisit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will properly delete in follow-up PRs rather than leave commented-out here !
What is working here
test:silent
which CI Github workflows expectjest-axe
forvitest-axe
& updates all a11y tests insrc/@planx/components
& beyondtoHaveNoViolations
(see thread)import "vitest-axe/extend-expect";
tosrc/setupTests.ts
axe
directly fromvitest-axe
and drops special config fromsrc/testUtils.ts
- does this seem okay? I don't think I've hit the SVG issue described in the code comment there yet / guessing it's old & since been resolved?jest
->vi
mocks along the way.skip()
s problematic ones so they're easier to globally search for in the final migration stretch!What's not working yet / let's address in a follow up PR ?
mockedAxios
are skipped - getting amockResolvedValueOnce
function not defined error (FileUploadAndLabel, Send)vi.spyOn()
for the "default" function are skipped (see thread, haven't quite sorted solution yet) (PlanningConstraints)Some unexpected linting stuff picked up with these changes has added extra noise to an already big PR, sorry!