Conversation
changelog: Internal, Code Quality, Add stricter linting for DOM testing
| submitButton = getByText('forms.buttons.submit.default'); | ||
| expect(isFormValid(submitButton.closest('form'))).to.be.true(); | ||
|
|
||
| // eslint-disable-next-line require-await |
There was a problem hiding this comment.
This change is somewhat strange and unexpected. Without it, it identifies the new Promise argument function as being async without and await call, but it's not an async function, and I'm not sure why it would suddenly start being flagged.
My guess is that some transitive dependency of what's changed in yarn.lock changed how the file is being parsed?
| "app/javascript/packages/verify-flow/**", | ||
| // In progress: enabling these rules for all files in packages/document-capture | ||
| "app/javascript/packages/document-capture/context/**", | ||
| "app/javascript/packages/document-capture/higher-order/**", |
There was a problem hiding this comment.
what's gonna lint this file to detect trailing spaces? 😛
| server.use(rest.post(locationsURL, (_req, res, ctx) => res(ctx.json([{ name: 'Baltimore' }])))); | ||
| server.use( | ||
| rest.post(locationsURL, (_req, res, ctx) => res(ctx.json([{ name: 'Baltimore' }]))), | ||
| rest.put(locationsURL, (_req, res, ctx) => res(ctx.json({ success: true }))), |
There was a problem hiding this comment.
was this like a missing stub?
There was a problem hiding this comment.
was this like a missing stub?
Yes, with the previous code, we weren't awaiting findAllByText, so the thing it was "clicking" was a promise object, not the intended button element. Clicking the button issues a network request before redirecting. Once the correction was made to await the result to click the button, these changes were also necessary to stub the resulting network response.
🛠 Summary of changes
Adds
eslint-plugin-testing-libraryto enforce additional lints surrounding expected usage of Testing Library related features.Why?
📜 Testing Plan
Verify that both lint and tests pass: