cypress-example-kitchensink
Advanced tools
Comparing version 1.0.2 to 1.0.5
@@ -112,3 +112,4 @@ /* global hljs, $ */ | ||
// begin: Handle our route logic ------------- | ||
let root = 'https://jsonplaceholder.typicode.com' | ||
// we fetch all data from this REST json backend | ||
const root = 'https://jsonplaceholder.cypress.io' | ||
@@ -115,0 +116,0 @@ function getComment () { |
@@ -219,2 +219,18 @@ /// <reference types="Cypress" /> | ||
it('.trigger() - trigger an event on a DOM element', () => { | ||
// https://on.cypress.io/trigger | ||
// To interact with a range input (slider) | ||
// we need to set its value & trigger the | ||
// event to signal it changed | ||
// Here, we invoke jQuery's val() method to set | ||
// the value and trigger the 'change' event | ||
cy.get('.trigger-input-range') | ||
.invoke('val', 25) | ||
.trigger('change') | ||
.get('input[type=range]').siblings('p') | ||
.should('have.text', '25') | ||
}) | ||
it('cy.scrollTo() - scroll the window or element to a position', () => { | ||
@@ -257,18 +273,2 @@ | ||
}) | ||
it('.trigger() - trigger an event on a DOM element', () => { | ||
// https://on.cypress.io/trigger | ||
// To interact with a range input (slider) | ||
// we need to set its value & trigger the | ||
// event to signal it changed | ||
// Here, we invoke jQuery's val() method to set | ||
// the value and trigger the 'change' event | ||
cy.get('.trigger-input-range') | ||
.invoke('val', 25) | ||
.trigger('change') | ||
.get('input[type=range]').siblings('p') | ||
.should('have.text', '25') | ||
}) | ||
}) |
@@ -30,5 +30,12 @@ /// <reference types="Cypress" /> | ||
expect(true).to.be.true | ||
const o = { foo: 'bar' } | ||
expect(o).to.equal(o) | ||
expect(o).to.deep.equal({ foo: 'bar' }) | ||
}) | ||
it('pass your own callback function to should()', () => { | ||
// Pass a function to should that can have any number | ||
// of explicit assertions within it. | ||
// The ".should(cb)" function will be retried | ||
// automatically until it passes all your explicit assertions or times out. | ||
cy.get('.assertions-p').find('p') | ||
@@ -57,2 +64,35 @@ .should(($p) => { | ||
it('finds element by class name regex', () => { | ||
cy.get('.docs-header').find('div') | ||
// .should(cb) callback function will be retried | ||
.should(($div) => { | ||
expect($div).to.have.length(1) | ||
const className = $div[0].className | ||
expect(className).to.match(/heading-/) | ||
}) | ||
// .then(cb) callback is not retried, | ||
// it either passes or fails | ||
.then(($div) => { | ||
expect($div).to.have.text('Introduction') | ||
}) | ||
}) | ||
it('can throw any error', () => { | ||
cy.get('.docs-header').find('div') | ||
.should(($div) => { | ||
if ($div.length !== 1) { | ||
// you can throw your own errors | ||
throw new Error('Did not find 1 element') | ||
} | ||
const className = $div[0].className | ||
if (!className.match(/heading-/)) { | ||
throw new Error(`Could not find class "heading-" in ${className}`) | ||
} | ||
}) | ||
}) | ||
it('assert - assert shape of an object', () => { | ||
@@ -59,0 +99,0 @@ const person = { |
@@ -213,1 +213,13 @@ /// <reference types="Cypress" /> | ||
}) | ||
context('Cypress.spec', () => { | ||
beforeEach(() => { | ||
cy.visit('http://localhost:8080/cypress-api') | ||
}) | ||
it('Get current spec information', () => { | ||
// https://on.cypress.io/spec | ||
// wrap the object so we can inspect it easily by clicking in the command log | ||
cy.wrap(Cypress.spec).should('have.keys', ['name', 'relative', 'absolute']) | ||
}) | ||
}) |
@@ -66,3 +66,3 @@ /// <reference types="Cypress" /> | ||
// generate a fixture file for use later | ||
cy.request('https://jsonplaceholder.typicode.com/users') | ||
cy.request('https://jsonplaceholder.cypress.io/users') | ||
.then((response) => { | ||
@@ -69,0 +69,0 @@ cy.writeFile('cypress/fixtures/users.json', response.body) |
@@ -50,3 +50,3 @@ /// <reference types="Cypress" /> | ||
// https://on.cypress.io/request | ||
cy.request('https://jsonplaceholder.typicode.com/comments') | ||
cy.request('https://jsonplaceholder.cypress.io/comments') | ||
.should((response) => { | ||
@@ -60,2 +60,33 @@ expect(response.status).to.eq(200) | ||
it('cy.request() - verify response using BDD syntax', () => { | ||
cy.request('https://jsonplaceholder.cypress.io/comments') | ||
.then((response) => { | ||
// https://on.cypress.io/assertions | ||
expect(response).property('status').to.equal(200) | ||
expect(response).property('body').to.have.length(500) | ||
expect(response).to.include.keys('headers', 'duration') | ||
}) | ||
}) | ||
it('cy.request() with query parameters', () => { | ||
// will execute request | ||
// https://jsonplaceholder.cypress.io/comments?postId=1&id=3 | ||
cy.request({ | ||
url: 'https://jsonplaceholder.cypress.io/comments', | ||
qs: { | ||
postId: 1, | ||
id: 3, | ||
}, | ||
}) | ||
.its('body') | ||
.should('be.an', 'array') | ||
.and('have.length', 1) | ||
.its('0') // yields first element of the array | ||
.should('contain', { | ||
postId: 1, | ||
id: 3, | ||
}) | ||
}) | ||
it('cy.route() - route responses to matching requests', () => { | ||
@@ -62,0 +93,0 @@ // https://on.cypress.io/route |
@@ -10,3 +10,3 @@ /// <reference types="Cypress" /> | ||
// https://on.cypress.io/_ | ||
cy.request('https://jsonplaceholder.typicode.com/users') | ||
cy.request('https://jsonplaceholder.cypress.io/users') | ||
.then((response) => { | ||
@@ -13,0 +13,0 @@ let ids = Cypress._.chain(response.body).map('id').take(3).value() |
{ | ||
"name": "cypress-example-kitchensink", | ||
"version": "1.0.2", | ||
"version": "1.0.5", | ||
"description": "This is an example app used to showcase Cypress.io testing. For a full reference of our documentation, go to docs.cypress.io", | ||
"main": "index.js", | ||
"files": [ | ||
"app", | ||
"cypress" | ||
], | ||
"scripts": { | ||
"build": "npm run lint && npm run types && npm run stop-only", | ||
"start": "http-server app -c-1", | ||
"start:ci": "http-server app -c-1 --silent", | ||
"dev": "npm start -- -o", | ||
"release": "releaser", | ||
"types": "tsc --noEmit", | ||
"test": "npm start & cypress run", | ||
"pretest": "npm run lint && npm run types", | ||
"print-env": "print-env", | ||
"lint": "eslint --fix cypress/**/*.js app/assets/js/scripts.js", | ||
@@ -19,13 +24,23 @@ "colon:names": "colon-names", | ||
"e2e:record": "cypress run --record", | ||
"e2e:record:parallel": "cypress run --record --parallel", | ||
"test:ci": "run-p --race start:ci e2e", | ||
"test:ci:chrome": "run-p --race start:ci e2e:chrome", | ||
"test:ci:record": "run-p --race start:ci e2e:record", | ||
"test:ci:record:parallel": "run-p --race start:ci e2e:record:parallel", | ||
"cy:verify": "cypress verify", | ||
"cy:version": "cypress version", | ||
"cy:run": "cypress run", | ||
"cy:open": "cypress open" | ||
"cy:run:record": "cypress run --record", | ||
"cy:open": "cypress open", | ||
"local:open": "start-test 8080 cy:open", | ||
"local:run": "start-test 8080 cy:run", | ||
"local:run:record": "start-test 8080 cy:run:record", | ||
"stop-only": "stop-only -f cypress/integration", | ||
"warn-only": "stop-only -f cypress/integration --warn", | ||
"ci:set-port": "node ./scripts/set-port", | ||
"semantic-release": "semantic-release" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+ssh://git@github.com/cypress-io/cypress-example-kitchensink.git" | ||
"url": "https://github.com/cypress-io/cypress-example-kitchensink.git" | ||
}, | ||
@@ -43,12 +58,26 @@ "author": "Brian Mann", | ||
"devDependencies": { | ||
"@cypress/releaser": "0.2.2", | ||
"@bahmutov/print-env": "1.1.0", | ||
"colon-names": "1.0.0", | ||
"cypress": "3.0.1", | ||
"eslint": "4.19.1", | ||
"eslint-plugin-cypress": "2.0.1", | ||
"cypress": "3.1.1", | ||
"eslint": "5.11.1", | ||
"eslint-plugin-cypress": "2.2.0", | ||
"eslint-plugin-cypress-dev": "1.1.2", | ||
"eslint-plugin-mocha": "5.0.0", | ||
"eslint-plugin-mocha": "5.2.0", | ||
"globby": "8.0.1", | ||
"husky": "1.3.1", | ||
"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" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "npm run warn-only", | ||
"pre-push": "npm run stop-only" | ||
} | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# Kitchen Sink [![Circle CI](https://circleci.com/gh/cypress-io/cypress-example-kitchensink.svg?style=svg)](https://circleci.com/gh/cypress-io/cypress-example-kitchensink) [![renovate-app badge][renovate-badge]][renovate-app] | ||
# Kitchen Sink [![renovate-app badge][renovate-badge]][renovate-app] | ||
@@ -14,10 +14,18 @@ ![kitchensink](https://cloud.githubusercontent.com/assets/1268976/14084252/e309e370-f4e7-11e5-9562-24f516563ac9.gif) | ||
Build status | CI | ||
:--- | :--- | ||
[![Travis CI](https://travis-ci.org/cypress-io/cypress-example-kitchensink.svg?branch=master)](https://travis-ci.org/cypress-io/cypress-example-kitchensink) | Travis | ||
[![Cypress Dashboard](https://img.shields.io/badge/cypress-dashboard-brightgreen.svg)](https://dashboard.cypress.io/#/projects/4b7344/runs) | Cypress Dashboard | ||
[![Build status](https://badge.buildkite.com/d1bd1f093d97de34475da7d545c80eb2be9749eefe1c7133f0.svg)](https://buildkite.com/cypress-io/cypress-example-kitchensink) | Buildkite | ||
[![Windows build status](https://ci.appveyor.com/api/projects/status/bo4x59pha1eb18de?svg=true)](https://ci.appveyor.com/project/cypress-io/cypress-example-kitchensink) | AppVeyor | ||
[ ![Codeship Status for cypress-io/cypress-example-kitchensink](https://app.codeship.com/projects/8d6a20c0-b70e-0133-41c6-56e5cd60fbd0/status?branch=master)](https://app.codeship.com/projects/134609) | Codeship Basic | ||
CI | Build status | basic config file | full parallel config | ||
:--- | :--- | :--- | :--- | ||
AppVeyor | [![AppVeyor CI](https://ci.appveyor.com/api/projects/status/bo4x59pha1eb18de?svg=true)](https://ci.appveyor.com/project/cypress-io/cypress-example-kitchensink) | [appveyor.yml](appveyor.yml) | ||
Azure CI | [![Build Status](https://cypress-io.visualstudio.com/cypress-example-kitchensink/_apis/build/status/cypress-example-kitchensink)](https://cypress-io.visualstudio.com/cypress-example-kitchensink/_build/latest?definitionId=1) | [basic/azure-ci.yml](basic/azure-ci.yml) | ||
Buildkite | [![Buildkite CI](https://badge.buildkite.com/d1bd1f093d97de34475da7d545c80eb2be9749eefe1c7133f0.svg)](https://buildkite.com/cypress-io/cypress-example-kitchensink) | [.buildkite/pipeline.yml](.buildkite/pipeline.yml) | ||
Circle | [![Circle CI](https://circleci.com/gh/cypress-io/cypress-example-kitchensink.svg?style=svg)](https://circleci.com/gh/cypress-io/cypress-example-kitchensink) | [basic/circle.yml](basic/circle.yml) | [circle.yml](circle.yml) | ||
Codeship Pro | [ ![Codeship Pro CI](https://app.codeship.com/projects/8d6a20c0-b70e-0133-41c6-56e5cd60fbd0/status?branch=master)](https://app.codeship.com/projects/134609) | [basic/codeship-pro](basic/codeship-pro) | ||
GitLab | [![GitLab CI](https://gitlab.com/cypress-io/cypress-example-kitchensink/badges/master/pipeline.svg)](https://gitlab.com/cypress-io/cypress-example-kitchensink/commits/master) | [basic/.gitlab-ci.yml](basic/.gitlab-ci.yml) | [.gitlab-ci.yml](.gitlab-ci.yml) | ||
Heroku CI | | [basic/app.json](basic/app.json) | | ||
Jenkins | | [basic/Jenkinsfile](basic/Jenkinsfile) | [Jenkinsfile](Jenkinsfile) | ||
Semaphore | [![Semaphore CI](https://semaphoreci.com/api/v1/cypress-io/cypress-example-kitchensink/branches/master/badge.svg)](https://semaphoreci.com/cypress-io/cypress-example-kitchensink) | ||
Shippable | [![Shippable CI](https://api.shippable.com/projects/56c38fdc1895ca4474743010/badge?branch=master)](https://app.shippable.com/github/cypress-io/cypress-example-kitchensink) | [shippable.yml](shippable.yml) | ||
Travis | [![Travis CI](https://travis-ci.org/cypress-io/cypress-example-kitchensink.svg?branch=master)](https://travis-ci.org/cypress-io/cypress-example-kitchensink) | [basic/.travis.yml](basic/.travis.yml) | [.travis.yml](.travis.yml) | ||
You can find all CI results recorded on the [![Cypress Dashboard](https://img.shields.io/badge/cypress-dashboard-brightgreen.svg)](https://dashboard.cypress.io/#/projects/4b7344/runs) | ||
## Help + Testing | ||
@@ -56,2 +64,9 @@ | ||
```bash | ||
## launch the cypress test runner | ||
npm run cy:open | ||
``` | ||
**shortcut:** you can use command `npm run local:open` that uses [start-server-and-test](https://github.com/bahmutov/start-server-and-test) to start local server and open Cypress. When you close Cypress, the local server is stopped automatically. Similarly you can use `npm run local:run` to start the server, run Cypress tests headlessly and close the server. | ||
### 2. Install & write tests in Cypress | ||
@@ -67,2 +82,14 @@ | ||
#### 1.0.4 - *(12/05/18)* | ||
- update image placeholder links to https | ||
- update cy.trigger example | ||
- add cy.request example with query params | ||
- update deps | ||
#### 1.0.3 - *(12/05/18)* | ||
- update image placeholder links to https | ||
- update cy.trigger example | ||
- add cy.request example with query params | ||
- update deps | ||
#### 1.0.2 - *(06/28/18)* | ||
@@ -69,0 +96,0 @@ - updated dependencies |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
197
2251742
14
62
2869
1