cypress-example-kitchensink
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -80,6 +80,7 @@ /// <reference types="Cypress" /> | ||
// array should have length of 3 | ||
expect(paragraphs).to.have.length(3) | ||
expect(paragraphs, 'has 3 paragraphs').to.have.length(3) | ||
// set this specific subject | ||
expect(paragraphs).to.deep.eq([ | ||
// use second argument to expect(...) to provide clear | ||
// message with each assertion | ||
expect(paragraphs, 'has expected text in each paragraph').to.deep.eq([ | ||
'Some text from first p', | ||
@@ -106,3 +107,3 @@ 'More text from second p', | ||
.then(($div) => { | ||
expect($div).to.have.text('Introduction') | ||
expect($div, 'text content').to.have.text('Introduction') | ||
}) | ||
@@ -128,2 +129,32 @@ }) | ||
it('matches unknown text between two elements', () => { | ||
/** | ||
* Text from the first element. | ||
* @type {string} | ||
*/ | ||
let text | ||
/** | ||
* Normalizes passed text, | ||
* useful before comparing text with spaces and different capitalization. | ||
* @param {string} s Text to normalize | ||
*/ | ||
const normalizeText = (s) => s.replace(/\s/g, '').toLowerCase() | ||
cy.get('.two-elements') | ||
.find('.first') | ||
.then(($first) => { | ||
// save text from the first element | ||
text = normalizeText($first.text()) | ||
}) | ||
cy.get('.two-elements') | ||
.find('.second') | ||
.should(($div) => { | ||
// we can massage text before comparing | ||
const secondText = normalizeText($div.text()) | ||
expect(secondText, 'second text').to.equal(text) | ||
}) | ||
}) | ||
it('assert - assert shape of an object', () => { | ||
@@ -130,0 +161,0 @@ const person = { |
@@ -49,9 +49,10 @@ /// <reference types="Cypress" /> | ||
// https://on.cypress.io/then | ||
cy.get('.connectors-list>li').then(($lis) => { | ||
expect($lis).to.have.length(3) | ||
expect($lis.eq(0)).to.contain('Walk the dog') | ||
expect($lis.eq(1)).to.contain('Feed the cat') | ||
expect($lis.eq(2)).to.contain('Write JavaScript') | ||
}) | ||
cy.get('.connectors-list > li') | ||
.then(($lis) => { | ||
expect($lis, '3 items').to.have.length(3) | ||
expect($lis.eq(0), 'first item').to.contain('Walk the dog') | ||
expect($lis.eq(1), 'second item').to.contain('Feed the cat') | ||
expect($lis.eq(2), 'third item').to.contain('Write JavaScript') | ||
}) | ||
}) | ||
}) |
{ | ||
"name": "cypress-example-kitchensink", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "This is an example app used to showcase Cypress.io testing. For a full reference of our documentation, go to docs.cypress.io", | ||
@@ -64,5 +64,5 @@ "main": "index.js", | ||
"eslint-plugin-mocha": "5.2.1", | ||
"globby": "8.0.1", | ||
"globby": "9.0.0", | ||
"husky": "1.3.1", | ||
"semantic-release": "15.13.2", | ||
"semantic-release": "15.13.3", | ||
"start-server-and-test": "1.7.11", | ||
@@ -69,0 +69,0 @@ "stop-build": "1.1.0", |
Sorry, the diff of this file is not supported yet
2260365
2937