You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it('should show a results link if results page exists', function () {
render(<DefaultStory />)
const link = screen.findByLabelText('Announcements.FinishedAnnouncement.seeResults')
expect(link).exists()
})
This test passes. ✅
const link = screen.findByLabelText('CALL ME ISHMAEL')
expect(link).exists()
This test ALSO passes! ❌
This is because .findBy... returns a Promise, which will always be .ok() and will always .exist()
Suggestion: rewrite tests to use .getBy... or .queryBy... instead. Or use await .findBy... where necessary. Example, for FinishedAnnouncementConnector.spec.js:
const link = screen.getByRole('link')
expect(link?.getAttribute('href')).to.equal('/projects/zookeeper/galaxy-zoo/about/results')
Dev Notes
This is a list of all `*.spec.js* files that use .findBy, as of 14 Oct 2024. I've linked to the _current_ (master) version instead of 4062f39 so you can quickly check if they're already patched.
❌ indicates the test isn't working correctly (i.e. giving false 'pass'es), as described in this issue.
✅ indicates that the test actually seems OK, since it uses e.g. await screen.findBy...(), which is the correct way to use Promises. (Not sure if it's worth double-checking.)
Status
Not urgent, but should be assigned on the next maintenance week. The incorrect tests means we're missing some safety nets that we assume are there.
The text was updated successfully, but these errors were encountered:
Incorrect Tests
Noted as of 4062f39
A number of our tests may be returning incorrect results, due to the use of
.findBy...
selectors.Example: FinishedAnnouncementConnector.spec.js
This test passes. ✅
This test ALSO passes! ❌
This is because
.findBy...
returns a Promise, which will always be .ok() and will always .exist()Suggestion: rewrite tests to use
.getBy...
or.queryBy...
instead. Or useawait .findBy...
where necessary. Example, for FinishedAnnouncementConnector.spec.js:Dev Notes
This is a list of all `*.spec.js* files that use .findBy, as of 14 Oct 2024. I've linked to the _current_ (master) version instead of 4062f39 so you can quickly check if they're already patched.
app-project
lib-classifier
lib-react-components
❌ indicates the test isn't working correctly (i.e. giving false 'pass'es), as described in this issue.
✅ indicates that the test actually seems OK, since it uses e.g.
await screen.findBy...()
, which is the correct way to use Promises. (Not sure if it's worth double-checking.)Status
Not urgent, but should be assigned on the next maintenance week. The incorrect tests means we're missing some safety nets that we assume are there.
The text was updated successfully, but these errors were encountered: