cypress-extender-arrays
v1.1.9
Published
Extends the functinality of Cypress to ease its usage.
Downloads
389
Maintainers
Readme
npm install cypress-extender-arrays
yarn add cypress-extender-arrays
Once cypress-extender-arrays is installed use:
import 'cypress-extender-arrays';
Or use:
require('cypress-extender-arrays');
Or add it to the plugin file.
cy.get('li').map(e => e.text().trim()).then(texts => {
cy.log('Texts are: ', texts);
});
cy.wrap([11,22,33]).map(e => e + 5).then(array => {
cy.wrap(array[0]).should('eq', 16);
cy.wrap(array[1]).should('eq', 27);
cy.wrap(array[2]).should('eq', 38);
});
it('test array reduce with array', () => {
cy.get('a').map(e => e.text()).reduce((acc, val) => {
acc.push(val[0]);
return acc;
}, []).should('have.length.gt', 0);
});
it('test array reduce with string', () => {
cy.get('a').map(e => e.text()).reduce((acc, val) => {
acc += val[0] || '';
return acc;
}, '').should('have.length.gt', 0);
});
it('test array reduce with number', () => {
cy.get('a').map(e => e.text()).reduce((acc, val) => acc += val.length, 0)
.should('be.gt', 0);
});
Use:
it('test that every from the prevSubjet is a string', () => {
cy.get('a').map(e => e.text()).every(v => typeof v === 'string').should('be.true');
});
Use:
it('test join texts are given', () => {
cy.get('a').map(e => e.text()).join("HOWAREYOU").should('include', 'HOWAREYOU');
});
Use:
it('test array reverse', () => {
cy.get('a').map(e => e.text()).reverse().then(values => {
cy.get('a').reverse().map(e => e.text()).should('deep.eq', values);
});
});