cypress-example-kitchensink
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -9,7 +9,32 @@ /// <reference types="Cypress" /> | ||
describe('Implicit Assertions', () => { | ||
it('.should() - make an assertion about the current subject', () => { | ||
// https://on.cypress.io/should | ||
cy.get('.assertion-table') | ||
.find('tbody tr:last').should('have.class', 'success') | ||
.find('tbody tr:last') | ||
.should('have.class', 'success') | ||
.find('td') | ||
.first() | ||
// checking the text of the <td> element in various ways | ||
.should('have.text', 'Column content') | ||
.should('contain', 'Column content') | ||
.should('have.html', 'Column content') | ||
// chai-jquery uses "is()" to check if element matches selector | ||
.should('match', 'td') | ||
// to match text content against a regular expression | ||
// first need to invoke jQuery method text() | ||
// and then match using regular expression | ||
.invoke('text') | ||
.should('match', /column content/i) | ||
// a better way to check element's text content against a regular expression | ||
// is to use "cy.contains" | ||
// https://on.cypress.io/contains | ||
cy.get('.assertion-table') | ||
.find('tbody tr:last') | ||
// finds first <td> element with text content matching regular expression | ||
.contains('td', /column content/i) | ||
.should('be.visible') | ||
// for more information about asserting element's text | ||
// see https://on.cypress.io/using-cypress-faq#How-do-I-get-an-element’s-text-contents | ||
}) | ||
@@ -34,2 +59,4 @@ | ||
expect(o).to.deep.equal({ foo: 'bar' }) | ||
// matching text using regular expression | ||
expect('FooBar').to.match(/bar$/i) | ||
}) | ||
@@ -42,27 +69,29 @@ | ||
// automatically until it passes all your explicit assertions or times out. | ||
cy.get('.assertions-p').find('p') | ||
.should(($p) => { | ||
// return an array of texts from all of the p's | ||
// @ts-ignore TS6133 unused variable | ||
const texts = $p.map((i, el) => // https://on.cypress.io/$ | ||
Cypress.$(el).text()) | ||
cy.get('.assertions-p') | ||
.find('p') | ||
.should(($p) => { | ||
// https://on.cypress.io/$ | ||
// return an array of texts from all of the p's | ||
// @ts-ignore TS6133 unused variable | ||
const texts = $p.map((i, el) => Cypress.$(el).text()) | ||
// jquery map returns jquery object | ||
// and .get() convert this to simple array | ||
const paragraphs = texts.get() | ||
// jquery map returns jquery object | ||
// and .get() convert this to simple array | ||
const paragraphs = texts.get() | ||
// array should have length of 3 | ||
expect(paragraphs).to.have.length(3) | ||
// array should have length of 3 | ||
expect(paragraphs).to.have.length(3) | ||
// set this specific subject | ||
expect(paragraphs).to.deep.eq([ | ||
'Some text from first p', | ||
'More text from second p', | ||
'And even more text from third p', | ||
]) | ||
}) | ||
// set this specific subject | ||
expect(paragraphs).to.deep.eq([ | ||
'Some text from first p', | ||
'More text from second p', | ||
'And even more text from third p', | ||
]) | ||
}) | ||
}) | ||
it('finds element by class name regex', () => { | ||
cy.get('.docs-header').find('div') | ||
cy.get('.docs-header') | ||
.find('div') | ||
// .should(cb) callback function will be retried | ||
@@ -84,3 +113,4 @@ .should(($div) => { | ||
it('can throw any error', () => { | ||
cy.get('.docs-header').find('div') | ||
cy.get('.docs-header') | ||
.find('div') | ||
.should(($div) => { | ||
@@ -87,0 +117,0 @@ if ($div.length !== 1) { |
{ | ||
"name": "cypress-example-kitchensink", | ||
"version": "1.1.0", | ||
"version": "1.2.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", | ||
@@ -63,10 +63,10 @@ "main": "index.js", | ||
"eslint-plugin-cypress-dev": "1.1.2", | ||
"eslint-plugin-mocha": "5.2.0", | ||
"eslint-plugin-mocha": "5.2.1", | ||
"globby": "8.0.1", | ||
"husky": "1.3.1", | ||
"semantic-release": "^15.13.2", | ||
"semantic-release": "15.13.2", | ||
"start-server-and-test": "1.7.11", | ||
"stop-build": "1.1.0", | ||
"stop-only": "2.2.4", | ||
"typescript": "2.9.2" | ||
"stop-only": "2.2.5", | ||
"typescript": "3.2.2" | ||
}, | ||
@@ -73,0 +73,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2257798
2909