How can I test it with multiple parameters with using test.each? #699
Answered
by
KeisukeNagakawa
KeisukeNagakawa
asked this question in
Q&A
-
Hi, first of all, thank you for this great code base. I'm appreciating it every day. I have a trouble using it with parametric tests. I have a code like this: it("with some ids as parameters ", async () => {
await testApiHandler({
handler: usersListHandler,
test: async ({ fetch }) => {
test.each`
id | expected
${"someID1} | ${200}
${"someID2"} | ${200}
`(`parameter loop`, async ({ id, exStatus }) => {
const response = await fetch({
body: JSON.stringify({id})
})
const status = response.status
expect(status).toBe(200)
})
},
})
}) which fails because of the following error:
What I would like to do is tesiting next-api with multiple parameters. Of course, I can solve it with using promise array and resolve it with |
Beta Was this translation helpful? Give feedback.
Answered by
KeisukeNagakawa
Oct 20, 2022
Replies: 1 comment 1 reply
-
Sorry... I solved it with myself. it.each`
id | expected
"someID1" | 200
"someID2" | 200
`("with some ids as parameters. id: $id, expected: $expected", async () => {
await testApiHandler({
handler: usersListHandler,
test: async ({ fetch }) => {
const response = await fetch({
body: JSON.stringify({id})
})
const status = response.status
expect(status).toBe(200)
}
},
})
}) Thanks! |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
KeisukeNagakawa
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry... I solved it with myself.
Thanks!