cypress-each
cypress-each copied to clipboard
string title function with array of arrays
// cypress/e2e/title-position.cy.js
describe('Positional title arguments', () => {
const list = [['foo', 'main']]
// @ts-ignore
it.each(list)('title is %1 and %0', (a, b) => {
expect(a, 'first').to.equal('foo')
expect(b, 'second').to.equal('main')
// @ts-ignore
expect(this.test.title, 'computed test title').to.equal(
'title is main and foo',
)
})
})
Need to use ts-ignore
otherwise getting an error
$ npm run lint
> [email protected] lint
> tsc --pretty --allowJs --strict --noEmit src/index.js cypress/**/*.js cypress/**/*.ts
cypress/e2e/title-position.cy.js:9:39 - error TS2345: Argument of type '(this: Context, a: any, b: any) => void' is not assignable to parameter of type '(this: Context, ...res: [...string[], any, any]) => void'.
Types of parameters 'a' and 'res_0' are incompatible.
Type '[...string[], any, any]' is not assignable to type '[a?: any, b?: any]'.
Target allows only 2 element(s) but source may have more.
9 it.each(list)('title is %1 and %0', function (a, b) {
~~~~~~~~
Found 1 error in cypress/e2e/title-position.cy.js:9