I'm getting an ESLint error Expect must have a corresponding matcher call - jest/valid-expect
on the first line in this loop where I'm checking for the matching regex (.toMatch
).
const dateRegex = /^([1-9]|1[012])[- \\/.]([1-9]|[12][0-9]|3[01])[- \\/.](19|20)\d\d/
expect(getPerformancePerUserPerDay(input).forEach((item, index) => {
expect(item['Date']).toMatch(dateRegex)
}))
Not sure what I'm doing wrong since the usage seems to be correct per their documentation. Could this be a bug?
I'm getting an ESLint error Expect must have a corresponding matcher call - jest/valid-expect
on the first line in this loop where I'm checking for the matching regex (.toMatch
).
const dateRegex = /^([1-9]|1[012])[- \\/.]([1-9]|[12][0-9]|3[01])[- \\/.](19|20)\d\d/
expect(getPerformancePerUserPerDay(input).forEach((item, index) => {
expect(item['Date']).toMatch(dateRegex)
}))
Not sure what I'm doing wrong since the usage seems to be correct per their documentation. Could this be a bug?
Share Improve this question edited Jul 31, 2020 at 21:45 skyboyer 23.8k7 gold badges62 silver badges71 bronze badges asked Jul 31, 2020 at 12:12 suuuriamsuuuriam 74714 silver badges27 bronze badges1 Answer
Reset to default 7The first expect
is not asserting anything, and according to the jest/valid-expect
rule Ensure expect() is called with a single argument and there is an actual expectation made.
this triggers an error.
Change to:
getPerformancePerUserPerDay(input).forEach((item, index) => {
expect(item['Date']).toMatch(dateRegex)
})