Open JessicaSachs opened 1 year ago
Here's a POC. It needs:
it.only
support for typesit.each = (cases: unknown[][]): any => {
// Whenever `it.each` is invoked.
return (testName: string, testItself: Function) => {
// Iterating over each case.
for (const myCase of cases) {
// Register the it function with Cypress
// TODO: Add string formatting that matches Jest || Vitest docs!
it(testName, () => {
// Cypress is actually invoking the test.
testItself.call(null, myCase);
})
}
}
}
Just learned about this in a Jest course. Would really appreciate this as well in Cypress.
@jdvegmond https://github.com/bahmutov/cypress-each
What would you like?
I'd like the functionality of
mocha-each
to be included in Cypress and its global types.Honestly, while it'd be nice to be in parity with Jest or Vitest, I don't mind the differences. I'd just like to be able to run an array through Cypress to generate N tests without having to implement test-name unique-ness each time.
I also think it's fine for the Command Log to treat them as sibling tests. I don't think it's necessary to make custom UI to handle
it.each
in Cypress.Why is this needed?
I'm switching some component tests away from Vitest/Jest at work and we use
it.each
in order to generate tests with distinctly unique names.This is so that the output generated by a reporter is unique and contains information about the inputs given to the
it
.@bahmutov has a POC for
cypress-each
that was created in the last 12 months which can be used as a starting point.Other
No response