cypress-example-kitchensink
Advanced tools
Comparing version 0.8.1 to 0.8.2
@@ -0,36 +1,38 @@ | ||
/* global hljs, $ */ | ||
// initialize highlight.js for JavaScript code highlighting | ||
hljs.initHighlightingOnLoad(); | ||
hljs.initHighlightingOnLoad() | ||
$(function () { | ||
// initialize Bootstrap popovers | ||
$('[data-toggle="popover"]').popover(); | ||
$('[data-toggle="popover"]').popover() | ||
// begin: draw dots on canvas on mouse click --- | ||
var canvas = document.getElementById('action-canvas'); | ||
let canvas = document.getElementById('action-canvas') | ||
var context; | ||
let context | ||
context = typeof canvas !== "undefined" && canvas !== null ? canvas.getContext('2d') : 0; | ||
context = typeof canvas !== 'undefined' && canvas !== null ? canvas.getContext('2d') : 0 | ||
$('#action-canvas').on('click', function(e) { | ||
draw(e); | ||
}); | ||
$('#action-canvas').on('click', function (e) { | ||
draw(e) | ||
}) | ||
function draw(e) { | ||
var pos = getMousePos(canvas, e); | ||
var posx = pos.x; | ||
var posy = pos.y; | ||
context.fillStyle = 'red'; | ||
context.beginPath(); | ||
context.arc(posx, posy, 5, 0, 2*Math.PI); | ||
context.fill(); | ||
function draw (e) { | ||
let pos = getMousePos(canvas, e) | ||
let posx = pos.x | ||
let posy = pos.y | ||
context.fillStyle = 'red' | ||
context.beginPath() | ||
context.arc(posx, posy, 5, 0, 2 * Math.PI) | ||
context.fill() | ||
} | ||
function getMousePos(canvas, evt) { | ||
var rect = canvas.getBoundingClientRect(); | ||
function getMousePos (canvas, evt) { | ||
let rect = canvas.getBoundingClientRect() | ||
return { | ||
x: evt.clientX - rect.left, | ||
y: evt.clientY - rect.top | ||
}; | ||
y: evt.clientY - rect.top, | ||
} | ||
} | ||
@@ -40,41 +42,41 @@ // end ----------------------------------------- | ||
// listen to dblclick to demonstrate logic on double click command | ||
$('.action-div').on('dblclick', function(e) { | ||
$('.action-input-hidden').removeClass('hidden').focus(); | ||
$(e.currentTarget).addClass('hidden'); | ||
}); | ||
$('.action-div').on('dblclick', function (e) { | ||
$('.action-input-hidden').removeClass('hidden').focus() | ||
$(e.currentTarget).addClass('hidden') | ||
}) | ||
// listen to focus to demonstrate logic on focus command | ||
$('.action-focus').on('focus', function(e) { | ||
$(e.currentTarget).addClass('focus'); | ||
$(e.currentTarget).prev().css('color', 'orange'); | ||
}); | ||
$('.action-focus').on('focus', function (e) { | ||
$(e.currentTarget).addClass('focus') | ||
$(e.currentTarget).prev().css('color', 'orange') | ||
}) | ||
// listen to blur to demonstrate logic on blur command | ||
$('.action-blur').on('blur', function(e) { | ||
$(e.currentTarget).addClass('error'); | ||
$(e.currentTarget).prev().css('color', 'red'); | ||
}); | ||
$('.action-blur').on('blur', function (e) { | ||
$(e.currentTarget).addClass('error') | ||
$(e.currentTarget).prev().css('color', 'red') | ||
}) | ||
// listen to submit to demonstrate logic on submit command | ||
$('.action-form').on('submit', function(e) { | ||
e.preventDefault(); | ||
$('.action-form').on('submit', function (e) { | ||
e.preventDefault() | ||
$('<p>Your form has been submitted!</p>') | ||
.insertAfter(e.currentTarget) | ||
.css('color', '#20B520'); | ||
}); | ||
.insertAfter(e.currentTarget) | ||
.css('color', '#20B520') | ||
}) | ||
// hide this div so we can invoke show later | ||
$('.connectors-div').hide(); | ||
$('.connectors-div').hide() | ||
// listen to click on misc-table | ||
$('.misc-table tr').on('click', function(e) { | ||
$(e.currentTarget).addClass('info'); | ||
}); | ||
$('.misc-table tr').on('click', function (e) { | ||
$(e.currentTarget).addClass('info') | ||
}) | ||
// listen to click on button in .as-table | ||
$('.as-table .btn').on('click', function(e) { | ||
e.preventDefault(); | ||
$(e.currentTarget).addClass('btn-success').text('Changed'); | ||
}); | ||
$('.as-table .btn').on('click', function (e) { | ||
e.preventDefault() | ||
$(e.currentTarget).addClass('btn-success').text('Changed') | ||
}) | ||
@@ -89,38 +91,38 @@ // listen to input range for trigger command | ||
$('.network-btn').on('click', function(e) { | ||
e.preventDefault(); | ||
getComment(e); | ||
}); | ||
$('.network-btn').on('click', function (e) { | ||
e.preventDefault() | ||
getComment(e) | ||
}) | ||
$('.network-post').on('click', function(e) { | ||
e.preventDefault(); | ||
postComment(e); | ||
}); | ||
$('.network-post').on('click', function (e) { | ||
e.preventDefault() | ||
postComment(e) | ||
}) | ||
$('.network-put').on('click', function(e) { | ||
e.preventDefault(); | ||
putComment(e); | ||
}); | ||
$('.network-put').on('click', function (e) { | ||
e.preventDefault() | ||
putComment(e) | ||
}) | ||
$('.fixture-btn').on('click', function(e) { | ||
e.preventDefault(); | ||
getComment(e); | ||
}); | ||
$('.fixture-btn').on('click', function (e) { | ||
e.preventDefault() | ||
getComment(e) | ||
}) | ||
// end ----------------------------------------- | ||
// begin: Handle our route logic ------------- | ||
var root = 'https://jsonplaceholder.typicode.com'; | ||
let root = 'https://jsonplaceholder.typicode.com' | ||
function getComment(e){ | ||
function getComment () { | ||
$.ajax({ | ||
url: root + '/comments/1', | ||
method: 'GET' | ||
}).then(function(data) { | ||
$('.network-comment').text(data.body); | ||
}); | ||
url: `${root}/comments/1`, | ||
method: 'GET', | ||
}).then(function (data) { | ||
$('.network-comment').text(data.body) | ||
}) | ||
} | ||
function postComment(e){ | ||
function postComment () { | ||
$.ajax({ | ||
url: root + '/comments', | ||
url: `${root}/comments`, | ||
method: 'POST', | ||
@@ -130,12 +132,12 @@ data: { | ||
email: 'hello@cypress.io', | ||
body: 'You can change the method used for cy.route() to be GET, POST, PUT, PATCH, or DELETE' | ||
} | ||
}).then(function(data) { | ||
$('.network-post-comment').text('POST successful!'); | ||
}); | ||
body: 'You can change the method used for cy.route() to be GET, POST, PUT, PATCH, or DELETE', | ||
}, | ||
}).then(function () { | ||
$('.network-post-comment').text('POST successful!') | ||
}) | ||
} | ||
function putComment(e){ | ||
function putComment () { | ||
$.ajax({ | ||
url: root + '/comments/1', | ||
url: `${root}/comments/1`, | ||
method: 'PUT', | ||
@@ -145,10 +147,10 @@ data: { | ||
email: 'hello@cypress.io', | ||
body: 'You can change the method used for cy.route() to be GET, POST, PUT, PATCH, or DELETE' | ||
body: 'You can change the method used for cy.route() to be GET, POST, PUT, PATCH, or DELETE', | ||
}, | ||
statusCode: { | ||
404: function(data) { | ||
$('.network-put-comment').text(data.responseJSON.error); | ||
} | ||
} | ||
}); | ||
404 (data) { | ||
$('.network-put-comment').text(data.responseJSON.error) | ||
}, | ||
}, | ||
}) | ||
} | ||
@@ -158,44 +160,43 @@ // end ----------------------------------------- | ||
$('.ls-btn').on('click', function(e) { | ||
e.preventDefault(); | ||
populateStorage(e); | ||
}); | ||
$('.ls-btn').on('click', function (e) { | ||
e.preventDefault() | ||
populateStorage(e) | ||
}) | ||
// populate local storage to demonstrate cy.clearLocalStorage() | ||
function populateStorage() { | ||
localStorage.setItem('prop1', 'red'); | ||
localStorage.setItem('prop2', 'blue'); | ||
localStorage.setItem('prop3', 'magenta'); | ||
function populateStorage () { | ||
localStorage.setItem('prop1', 'red') | ||
localStorage.setItem('prop2', 'blue') | ||
localStorage.setItem('prop3', 'magenta') | ||
} | ||
// setting a cookie | ||
$('.set-a-cookie').on('click', function(e) { | ||
e.preventDefault(); | ||
setCookies(e); | ||
}); | ||
$('.set-a-cookie').on('click', function (e) { | ||
e.preventDefault() | ||
setCookies(e) | ||
}) | ||
// populate local cookie to demonstrate cy.clearCookies() | ||
function setCookies(e) { | ||
document.cookie = 'token=123ABC'; | ||
function setCookies () { | ||
document.cookie = 'token=123ABC' | ||
} | ||
$('.utility-jquery li').on('click', function(e) { | ||
var $li = $(e.currentTarget) | ||
$li.addClass("active") | ||
}); | ||
$('.utility-jquery li').on('click', function (e) { | ||
let $li = $(e.currentTarget) | ||
$li.addClass('active') | ||
}) | ||
$('#clock-div').on('click', function(e) { | ||
var $div = $(e.currentTarget) | ||
$('#clock-div').on('click', function (e) { | ||
let $div = $(e.currentTarget) | ||
// seconds from the unix epoch | ||
$div.text(new Date().getTime() / 1000) | ||
}); | ||
}) | ||
$('#tick-div').on('click', function(e) { | ||
var $div = $(e.currentTarget) | ||
$('#tick-div').on('click', function (e) { | ||
let $div = $(e.currentTarget) | ||
// seconds from the unix epoch | ||
$div.text(new Date().getTime() / 1000) | ||
}); | ||
}); | ||
}) | ||
}) |
@@ -1,1 +0,3 @@ | ||
{} | ||
{ | ||
"projectId": "4b7344" | ||
} |
@@ -14,4 +14,4 @@ // | ||
describe('Kitchen Sink', function(){ | ||
it('.should() - assert that <title> is correct', function(){ | ||
describe('Kitchen Sink', function () { | ||
it('.should() - assert that <title> is correct', function () { | ||
// https://on.cypress.io/visit | ||
@@ -32,4 +32,4 @@ cy.visit('http://localhost:8080') | ||
context('Querying', function(){ | ||
beforeEach(function(){ | ||
context('Querying', function () { | ||
beforeEach(function () { | ||
// Visiting our app before each test removes any state build up from | ||
@@ -44,3 +44,3 @@ // previous tests. Visiting acts as if we closed a tab and opened a fresh one | ||
it('cy.get() - query DOM elements', function(){ | ||
it('cy.get() - query DOM elements', function () { | ||
// https://on.cypress.io/get | ||
@@ -59,3 +59,3 @@ | ||
it('cy.contains() - query DOM elements with matching content', function(){ | ||
it('cy.contains() - query DOM elements with matching content', function () { | ||
// https://on.cypress.io/contains | ||
@@ -84,5 +84,5 @@ cy.get('.query-list') | ||
it('.within() - query DOM elements within a specific element', function(){ | ||
it('.within() - query DOM elements within a specific element', function () { | ||
// https://on.cypress.io/within | ||
cy.get('.query-form').within(function(){ | ||
cy.get('.query-form').within(function () { | ||
cy.get('input:first').should('have.attr', 'placeholder', 'Email') | ||
@@ -93,3 +93,3 @@ cy.get('input:last').should('have.attr', 'placeholder', 'Password') | ||
it('cy.root() - query the root DOM element', function(){ | ||
it('cy.root() - query the root DOM element', function () { | ||
// https://on.cypress.io/root | ||
@@ -99,3 +99,3 @@ // By default, root is the document | ||
cy.get('.query-ul').within(function(){ | ||
cy.get('.query-ul').within(function () { | ||
// In this within, the root is now the ul DOM element | ||
@@ -107,4 +107,4 @@ cy.root().should('have.class', 'query-ul') | ||
context('Traversal', function(){ | ||
beforeEach(function(){ | ||
context('Traversal', function () { | ||
beforeEach(function () { | ||
cy.visit('http://localhost:8080/commands/traversal') | ||
@@ -115,3 +115,3 @@ }) | ||
it('.children() - get child DOM elements', function(){ | ||
it('.children() - get child DOM elements', function () { | ||
// https://on.cypress.io/children | ||
@@ -122,3 +122,3 @@ cy.get('.traversal-breadcrumb').children('.active') | ||
it('.closest() - get closest ancestor DOM element', function(){ | ||
it('.closest() - get closest ancestor DOM element', function () { | ||
// https://on.cypress.io/closest | ||
@@ -129,3 +129,3 @@ cy.get('.traversal-badge').closest('ul') | ||
it('.eq() - get a DOM element at a specific index', function(){ | ||
it('.eq() - get a DOM element at a specific index', function () { | ||
// https://on.cypress.io/eq | ||
@@ -135,3 +135,3 @@ cy.get('.traversal-list>li').eq(1).should('contain', 'siamese') | ||
it('.filter() - get DOM elements that match the selector', function(){ | ||
it('.filter() - get DOM elements that match the selector', function () { | ||
// https://on.cypress.io/filter | ||
@@ -141,3 +141,3 @@ cy.get('.traversal-nav>li').filter('.active').should('contain', 'About') | ||
it('.find() - get descendant DOM elements of the selector', function(){ | ||
it('.find() - get descendant DOM elements of the selector', function () { | ||
// https://on.cypress.io/find | ||
@@ -148,3 +148,3 @@ cy.get('.traversal-pagination').find('li').find('a') | ||
it('.first() - get first DOM element', function(){ | ||
it('.first() - get first DOM element', function () { | ||
// https://on.cypress.io/first | ||
@@ -154,3 +154,3 @@ cy.get('.traversal-table td').first().should('contain', '1') | ||
it('.last() - get last DOM element', function(){ | ||
it('.last() - get last DOM element', function () { | ||
// https://on.cypress.io/last | ||
@@ -160,3 +160,3 @@ cy.get('.traversal-buttons .btn').last().should('contain', 'Submit') | ||
it('.next() - get next sibling DOM element', function(){ | ||
it('.next() - get next sibling DOM element', function () { | ||
// https://on.cypress.io/next | ||
@@ -166,3 +166,3 @@ cy.get('.traversal-ul').contains('apples').next().should('contain', 'oranges') | ||
it('.nextAll() - get all next sibling DOM elements', function(){ | ||
it('.nextAll() - get all next sibling DOM elements', function () { | ||
// https://on.cypress.io/nextall | ||
@@ -173,3 +173,3 @@ cy.get('.traversal-next-all').contains('oranges') | ||
it('.nextUntil() - get next sibling DOM elements until next el', function(){ | ||
it('.nextUntil() - get next sibling DOM elements until next el', function () { | ||
// https://on.cypress.io/nextuntil | ||
@@ -179,3 +179,3 @@ cy.get('#veggies').nextUntil('#nuts').should('have.length', 3) | ||
it('.not() - remove DOM elements from set of DOM elements', function(){ | ||
it('.not() - remove DOM elements from set of DOM elements', function () { | ||
// https://on.cypress.io/not | ||
@@ -185,3 +185,3 @@ cy.get('.traversal-disabled .btn').not('[disabled]').should('not.contain', 'Disabled') | ||
it('.parent() - get parent DOM element from DOM elements', function(){ | ||
it('.parent() - get parent DOM element from DOM elements', function () { | ||
// https://on.cypress.io/parent | ||
@@ -191,3 +191,3 @@ cy.get('.traversal-mark').parent().should('contain', 'Morbi leo risus') | ||
it('.parents() - get parent DOM elements from DOM elements', function(){ | ||
it('.parents() - get parent DOM elements from DOM elements', function () { | ||
// https://on.cypress.io/parents | ||
@@ -197,3 +197,3 @@ cy.get('.traversal-cite').parents().should('match', 'blockquote') | ||
it('.parentsUntil() - get parent DOM elements from DOM elements until el', function(){ | ||
it('.parentsUntil() - get parent DOM elements from DOM elements until el', function () { | ||
// https://on.cypress.io/parentsuntil | ||
@@ -204,3 +204,3 @@ cy.get('.clothes-nav').find('.active').parentsUntil('.clothes-nav') | ||
it('.prev() - get previous sibling DOM element', function(){ | ||
it('.prev() - get previous sibling DOM element', function () { | ||
// https://on.cypress.io/prev | ||
@@ -210,3 +210,3 @@ cy.get('.birds').find('.active').prev().should('contain', 'Lorikeets') | ||
it('.prevAll() - get all previous sibling DOM elements', function(){ | ||
it('.prevAll() - get all previous sibling DOM elements', function () { | ||
// https://on.cypress.io/prevAll | ||
@@ -216,3 +216,3 @@ cy.get('.fruits-list').find('.third').prevAll().should('have.length', 2) | ||
it('.prevUntil() - get all previous sibling DOM elements until el', function(){ | ||
it('.prevUntil() - get all previous sibling DOM elements until el', function () { | ||
// https://on.cypress.io/prevUntil | ||
@@ -222,3 +222,3 @@ cy.get('.foods-list').find('#nuts').prevUntil('#veggies') | ||
it('.siblings() - get all sibling DOM elements', function(){ | ||
it('.siblings() - get all sibling DOM elements', function () { | ||
// https://on.cypress.io/siblings | ||
@@ -229,4 +229,4 @@ cy.get('.traversal-pills .active').siblings().should('have.length', 2) | ||
context('Actions', function(){ | ||
beforeEach(function(){ | ||
context('Actions', function () { | ||
beforeEach(function () { | ||
cy.visit('http://localhost:8080/commands/actions') | ||
@@ -238,3 +238,3 @@ }) | ||
it('.type() - type into a DOM element', function(){ | ||
it('.type() - type into a DOM element', function () { | ||
// https://on.cypress.io/type | ||
@@ -249,4 +249,4 @@ cy.get('.action-email') | ||
// .type() with key modifiers | ||
.type('{alt}{option}') //these are equivalent | ||
.type('{ctrl}{control}') //these are equivalent | ||
.type('{alt}{option}') //these are equivalent | ||
.type('{ctrl}{control}') //these are equivalent | ||
.type('{meta}{command}{cmd}') //these are equivalent | ||
@@ -256,3 +256,3 @@ .type('{shift}') | ||
// Delay each keypress by 0.1 sec | ||
.type('slow.typing@email.com', {delay: 100}) | ||
.type('slow.typing@email.com', { delay: 100 }) | ||
.should('have.value', 'slow.typing@email.com') | ||
@@ -263,7 +263,7 @@ | ||
// like whether the input is visible or disabled | ||
.type('disabled error checking', {force: true}) | ||
.type('disabled error checking', { force: true }) | ||
.should('have.value', 'disabled error checking') | ||
}) | ||
it('.focus() - focus on a DOM element', function(){ | ||
it('.focus() - focus on a DOM element', function () { | ||
// https://on.cypress.io/focus | ||
@@ -275,3 +275,3 @@ cy.get('.action-focus').focus() | ||
it('.blur() - blur off a DOM element', function(){ | ||
it('.blur() - blur off a DOM element', function () { | ||
// https://on.cypress.io/blur | ||
@@ -283,3 +283,3 @@ cy.get('.action-blur').type('I\'m about to blur').blur() | ||
it('.clear() - clears an input or textarea element', function(){ | ||
it('.clear() - clears an input or textarea element', function () { | ||
// https://on.cypress.io/clear | ||
@@ -292,3 +292,3 @@ cy.get('.action-clear').type('We are going to clear this text') | ||
it('.submit() - submit a form', function(){ | ||
it('.submit() - submit a form', function () { | ||
// https://on.cypress.io/submit | ||
@@ -301,3 +301,3 @@ cy.get('.action-form') | ||
it('.click() - click on a DOM element', function(){ | ||
it('.click() - click on a DOM element', function () { | ||
// https://on.cypress.io/click | ||
@@ -344,3 +344,3 @@ cy.get('.action-btn').click() | ||
// click multiple elements by passing multiple: true | ||
cy.get('.action-labels>.label').click({multiple: true}) | ||
cy.get('.action-labels>.label').click({ multiple: true }) | ||
@@ -350,6 +350,6 @@ // Ignore error checking prior to clicking | ||
// this button below is covered by another element. | ||
cy.get('.action-opacity>.btn').click({force: true}) | ||
cy.get('.action-opacity>.btn').click({ force: true }) | ||
}) | ||
it('.dblclick() - double click on a DOM element', function(){ | ||
it('.dblclick() - double click on a DOM element', function () { | ||
// Our app has a listener on 'dblclick' event in our 'scripts.js' | ||
@@ -363,3 +363,3 @@ // that hides the div and shows an input on double click | ||
it('cy.check() - check a checkbox or radio element', function(){ | ||
it('cy.check() - check a checkbox or radio element', function () { | ||
// By default, .check() will check all | ||
@@ -390,9 +390,9 @@ // matching checkbox or radio elements in succession, one after another | ||
cy.get('.action-checkboxes [disabled]') | ||
.check({force: true}).should('be.checked') | ||
.check({ force: true }).should('be.checked') | ||
cy.get('.action-radios [type="radio"]') | ||
.check('radio3', {force: true}).should('be.checked') | ||
.check('radio3', { force: true }).should('be.checked') | ||
}) | ||
it('.uncheck() - uncheck a checkbox element', function(){ | ||
it('.uncheck() - uncheck a checkbox element', function () { | ||
// By default, .uncheck() will uncheck all matching | ||
@@ -424,6 +424,6 @@ // checkbox elements in succession, one after another | ||
cy.get('.action-check [disabled]') | ||
.uncheck({force: true}).should('not.be.checked') | ||
.uncheck({ force: true }).should('not.be.checked') | ||
}) | ||
it('.select() - select an option in a <select> element', function(){ | ||
it('.select() - select an option in a <select> element', function () { | ||
// https://on.cypress.io/select | ||
@@ -446,3 +446,3 @@ | ||
it('.scrollIntoView() - scroll an element into view', function(){ | ||
it('.scrollIntoView() - scroll an element into view', function () { | ||
// https://on.cypress.io/scrollintoview | ||
@@ -474,3 +474,3 @@ | ||
it('cy.scrollTo() - scroll the window or element to a position', function(){ | ||
it('cy.scrollTo() - scroll the window or element to a position', function () { | ||
@@ -507,9 +507,9 @@ // https://on.cypress.io/scrollTo | ||
// control the easing of the scroll (default is 'swing') | ||
cy.get('#scrollable-vertical').scrollTo('center', {easing: 'linear'} ) | ||
cy.get('#scrollable-vertical').scrollTo('center', { easing: 'linear' }) | ||
// control the duration of the scroll (in ms) | ||
cy.get('#scrollable-both').scrollTo('center', {duration: 2000} ) | ||
cy.get('#scrollable-both').scrollTo('center', { duration: 2000 }) | ||
}) | ||
it('.trigger() - trigger an event on a DOM element', function(){ | ||
it('.trigger() - trigger an event on a DOM element', function () { | ||
// To interact with a range input (slider), we need to set its value and | ||
@@ -537,8 +537,8 @@ // then trigger the appropriate event to signal it has changed | ||
context('Window', function(){ | ||
beforeEach(function(){ | ||
context('Window', function () { | ||
beforeEach(function () { | ||
cy.visit('http://localhost:8080/commands/window') | ||
}) | ||
it('cy.window() - get the global window object', function(){ | ||
it('cy.window() - get the global window object', function () { | ||
// https://on.cypress.io/window | ||
@@ -548,3 +548,3 @@ cy.window().should('have.property', 'top') | ||
it('cy.document() - get the document object', function(){ | ||
it('cy.document() - get the document object', function () { | ||
// https://on.cypress.io/document | ||
@@ -554,3 +554,3 @@ cy.document().should('have.property', 'charset').and('eq', 'UTF-8') | ||
it('cy.title() - get the title', function(){ | ||
it('cy.title() - get the title', function () { | ||
// https://on.cypress.io/title | ||
@@ -561,8 +561,8 @@ cy.title().should('include', 'Kitchen Sink') | ||
context('Viewport', function(){ | ||
beforeEach(function(){ | ||
context('Viewport', function () { | ||
beforeEach(function () { | ||
cy.visit('http://localhost:8080/commands/viewport') | ||
}) | ||
it('cy.viewport() - set the viewport size and dimension', function(){ | ||
it('cy.viewport() - set the viewport size and dimension', function () { | ||
@@ -621,4 +621,4 @@ cy.get('#navbar').should('be.visible') | ||
context('Location', function(){ | ||
beforeEach(function(){ | ||
context('Location', function () { | ||
beforeEach(function () { | ||
cy.visit('http://localhost:8080/commands/location') | ||
@@ -630,3 +630,3 @@ }) | ||
it('cy.hash() - get the current URL hash', function(){ | ||
it('cy.hash() - get the current URL hash', function () { | ||
// https://on.cypress.io/hash | ||
@@ -636,5 +636,5 @@ cy.hash().should('be.empty') | ||
it('cy.location() - get window.location', function(){ | ||
it('cy.location() - get window.location', function () { | ||
// https://on.cypress.io/location | ||
cy.location().should(function(location){ | ||
cy.location().should(function (location) { | ||
expect(location.hash).to.be.empty | ||
@@ -652,3 +652,3 @@ expect(location.href).to.eq('http://localhost:8080/commands/location') | ||
it('cy.url() - get the current URL', function(){ | ||
it('cy.url() - get the current URL', function () { | ||
// https://on.cypress.io/url | ||
@@ -659,4 +659,4 @@ cy.url().should('eq', 'http://localhost:8080/commands/location') | ||
context('Navigation', function(){ | ||
beforeEach(function(){ | ||
context('Navigation', function () { | ||
beforeEach(function () { | ||
cy.visit('http://localhost:8080') | ||
@@ -667,3 +667,3 @@ cy.get('.navbar-nav').contains('Commands').click() | ||
it('cy.go() - go back or forward in the browser\'s history', function(){ | ||
it('cy.go() - go back or forward in the browser\'s history', function () { | ||
cy.location('pathname').should('include', 'navigation') | ||
@@ -687,3 +687,3 @@ | ||
it('cy.reload() - reload the page', function(){ | ||
it('cy.reload() - reload the page', function () { | ||
// https://on.cypress.io/reload | ||
@@ -696,3 +696,3 @@ cy.reload() | ||
it('cy.visit() - visit a remote url', function(){ | ||
it('cy.visit() - visit a remote url', function () { | ||
/* eslint-disable no-unused-vars */ | ||
@@ -705,8 +705,8 @@ // Visit any sub-domain of your current domain | ||
timeout: 50000, // increase total time for the visit to resolve | ||
onBeforeLoad: function(contentWindow){ | ||
onBeforeLoad (contentWindow) { | ||
// contentWindow is the remote page's window object | ||
}, | ||
onLoad: function(contentWindow){ | ||
onLoad (contentWindow) { | ||
// contentWindow is the remote page's window object | ||
} | ||
}, | ||
}) | ||
@@ -717,10 +717,10 @@ /* eslint-enable no-unused-vars */ | ||
context('Assertions', function(){ | ||
beforeEach(function(){ | ||
context('Assertions', function () { | ||
beforeEach(function () { | ||
cy.visit('http://localhost:8080/commands/assertions') | ||
}) | ||
describe('Implicit Assertions', function(){ | ||
describe('Implicit Assertions', function () { | ||
it('.should() - make an assertion about the current subject', function(){ | ||
it('.should() - make an assertion about the current subject', function () { | ||
// https://on.cypress.io/should | ||
@@ -731,3 +731,3 @@ cy.get('.assertion-table') | ||
it('.and() - chain multiple assertions together', function(){ | ||
it('.and() - chain multiple assertions together', function () { | ||
// https://on.cypress.io/and | ||
@@ -741,4 +741,13 @@ cy.get('.assertions-link') | ||
describe('Explicit Assertions', function(){ | ||
it('expect - make an assertion about a specified subject', function(){ | ||
describe('Explicit Assertions', function () { | ||
// https://on.cypress.io/assertions | ||
it('expect - assert shape of an object', function () { | ||
const person = { | ||
name: 'Joe', | ||
age: 20, | ||
} | ||
expect(person).to.have.all.keys('name', 'age') | ||
}) | ||
it('expect - make an assertion about a specified subject', function () { | ||
// We can use Chai's BDD style assertions | ||
@@ -750,23 +759,23 @@ expect(true).to.be.true | ||
cy.get('.assertions-p').find('p') | ||
.should(function($p){ | ||
// return an array of texts from all of the p's | ||
var texts = $p.map(function(i, el){ | ||
// https://on.cypress.io/$ | ||
return Cypress.$(el).text() | ||
}) | ||
.should(function ($p) { | ||
// return an array of texts from all of the p's | ||
let texts = $p.map(function (i, el) { | ||
// https://on.cypress.io/$ | ||
return Cypress.$(el).text() | ||
}) | ||
// jquery map returns jquery object | ||
// and .get() convert this to simple array | ||
texts = texts.get() | ||
// jquery map returns jquery object | ||
// and .get() convert this to simple array | ||
texts = texts.get() | ||
// array should have length of 3 | ||
expect(texts).to.have.length(3) | ||
// array should have length of 3 | ||
expect(texts).to.have.length(3) | ||
// set this specific subject | ||
expect(texts).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(texts).to.deep.eq([ | ||
'Some text from first p', | ||
'More text from second p', | ||
'And even more text from third p', | ||
]) | ||
}) | ||
}) | ||
@@ -776,8 +785,8 @@ }) | ||
context('Misc', function(){ | ||
beforeEach(function(){ | ||
context('Misc', function () { | ||
beforeEach(function () { | ||
cy.visit('http://localhost:8080/commands/misc') | ||
}) | ||
it('.end() - end the command chain', function(){ | ||
it('.end() - end the command chain', function () { | ||
// cy.end is useful when you want to end a chain of commands | ||
@@ -787,3 +796,3 @@ // and force Cypress to re-query from the root element | ||
// https://on.cypress.io/end | ||
cy.get('.misc-table').within(function(){ | ||
cy.get('.misc-table').within(function () { | ||
// ends the current chain and yields null | ||
@@ -797,3 +806,3 @@ cy.contains('Cheryl').click().end() | ||
it('cy.exec() - execute a system command', function(){ | ||
it('cy.exec() - execute a system command', function () { | ||
// cy.exec allows you to execute a system command. | ||
@@ -814,3 +823,3 @@ // so you can take actions necessary for your test, | ||
it('cy.focused() - get the DOM element that has focus', function(){ | ||
it('cy.focused() - get the DOM element that has focus', function () { | ||
// https://on.cypress.io/focused | ||
@@ -824,3 +833,3 @@ cy.get('.misc-form').find('#name').click() | ||
it('cy.screenshot() - take a screenshot', function(){ | ||
it('cy.screenshot() - take a screenshot', function () { | ||
// https://on.cypress.io/screenshot | ||
@@ -830,5 +839,5 @@ cy.screenshot('my-image') | ||
it('cy.wrap() - wrap an object', function(){ | ||
it('cy.wrap() - wrap an object', function () { | ||
// https://on.cypress.io/wrap | ||
cy.wrap({foo: 'bar'}) | ||
cy.wrap({ foo: 'bar' }) | ||
.should('have.property', 'foo') | ||
@@ -839,11 +848,11 @@ .and('include', 'bar') | ||
context('Connectors', function(){ | ||
beforeEach(function(){ | ||
context('Connectors', function () { | ||
beforeEach(function () { | ||
cy.visit('http://localhost:8080/commands/connectors') | ||
}) | ||
it('.each() - iterate over an array of elements', function(){ | ||
it('.each() - iterate over an array of elements', function () { | ||
// https://on.cypress.io/each | ||
cy.get('.connectors-each-ul>li') | ||
.each(function($el, index, $list){ | ||
.each(function ($el, index, $list) { | ||
// eslint-disable-next-line no-console | ||
@@ -854,3 +863,3 @@ console.log($el, index, $list) | ||
it('.its() - get properties on the current subject', function(){ | ||
it('.its() - get properties on the current subject', function () { | ||
// https://on.cypress.io/its | ||
@@ -863,3 +872,3 @@ cy.get('.connectors-its-ul>li') | ||
it('.invoke() - invoke a function on the current subject', function(){ | ||
it('.invoke() - invoke a function on the current subject', function () { | ||
// our div is hidden in our script.js | ||
@@ -876,7 +885,7 @@ // $('.connectors-div').hide() | ||
it('.spread() - spread an array as individual args to callback function', function(){ | ||
it('.spread() - spread an array as individual args to callback function', function () { | ||
// https://on.cypress.io/spread | ||
var arr = ['foo', 'bar', 'baz'] | ||
let arr = ['foo', 'bar', 'baz'] | ||
cy.wrap(arr).spread(function(foo, bar, baz){ | ||
cy.wrap(arr).spread(function (foo, bar, baz) { | ||
expect(foo).to.eq('foo') | ||
@@ -888,5 +897,5 @@ expect(bar).to.eq('bar') | ||
it('.then() - invoke a callback function with the current subject', function(){ | ||
it('.then() - invoke a callback function with the current subject', function () { | ||
// https://on.cypress.io/then | ||
cy.get('.connectors-list>li').then(function($lis){ | ||
cy.get('.connectors-list>li').then(function ($lis) { | ||
expect($lis).to.have.length(3) | ||
@@ -900,4 +909,4 @@ expect($lis.eq(0)).to.contain('Walk the dog') | ||
context('Aliasing', function(){ | ||
beforeEach(function(){ | ||
context('Aliasing', function () { | ||
beforeEach(function () { | ||
cy.visit('http://localhost:8080/commands/aliasing') | ||
@@ -910,3 +919,3 @@ }) | ||
it('.as() - alias a route or DOM element for later use', function(){ | ||
it('.as() - alias a route or DOM element for later use', function () { | ||
// this is a good use case for an alias, | ||
@@ -931,4 +940,4 @@ // we don't want to write this long traversal again | ||
context('Waiting', function(){ | ||
beforeEach(function(){ | ||
context('Waiting', function () { | ||
beforeEach(function () { | ||
cy.visit('http://localhost:8080/commands/waiting') | ||
@@ -939,3 +948,3 @@ }) | ||
// https://on.cypress.io/wait | ||
it('cy.wait() - wait for a specific amount of time', function(){ | ||
it('cy.wait() - wait for a specific amount of time', function () { | ||
cy.get('.wait-input1').type('Wait 1000ms after typing') | ||
@@ -953,4 +962,4 @@ cy.wait(1000) | ||
context('Network Requests', function(){ | ||
beforeEach(function(){ | ||
context('Network Requests', function () { | ||
beforeEach(function () { | ||
cy.visit('http://localhost:8080/commands/network-requests') | ||
@@ -961,5 +970,5 @@ }) | ||
it('cy.server() - control behavior of network requests and responses', function(){ | ||
it('cy.server() - control behavior of network requests and responses', function () { | ||
// https://on.cypress.io/server | ||
cy.server().should(function(server){ | ||
cy.server().should(function (server) { | ||
// the default options on server | ||
@@ -991,3 +1000,3 @@ // you can override any of these options | ||
status: 422, | ||
response: {} | ||
response: {}, | ||
}) | ||
@@ -1000,6 +1009,6 @@ | ||
it('cy.request() - make an XHR request', function(){ | ||
it('cy.request() - make an XHR request', function () { | ||
// https://on.cypress.io/request | ||
cy.request('https://jsonplaceholder.typicode.com/comments') | ||
.should(function(response){ | ||
.should(function (response) { | ||
expect(response.status).to.eq(200) | ||
@@ -1012,4 +1021,4 @@ expect(response.body).to.have.length(500) | ||
it('cy.route() - route responses to matching requests', function(){ | ||
var message = 'whoa, this comment doesn\'t exist' | ||
it('cy.route() - route responses to matching requests', function () { | ||
let message = 'whoa, this comment doesn\'t exist' | ||
cy.server() | ||
@@ -1045,3 +1054,3 @@ | ||
// get the route | ||
cy.get('@postComment').then(function(xhr){ | ||
cy.get('@postComment').then(function (xhr) { | ||
expect(xhr.requestBody).to.include('email') | ||
@@ -1057,4 +1066,4 @@ expect(xhr.requestHeaders).to.have.property('Content-Type') | ||
status: 404, | ||
response: {error: message}, | ||
delay: 500 | ||
response: { error: message }, | ||
delay: 500, | ||
}).as('putComment') | ||
@@ -1073,7 +1082,7 @@ | ||
context('Files', function(){ | ||
beforeEach(function(){ | ||
context('Files', function () { | ||
beforeEach(function () { | ||
cy.visit('http://localhost:8080/commands/files') | ||
}) | ||
it('cy.fixture() - load a fixture', function(){ | ||
it('cy.fixture() - load a fixture', function () { | ||
// Instead of writing a response inline you can | ||
@@ -1122,3 +1131,3 @@ // connect a response with a fixture file | ||
it('cy.readFile() - read a files contents', function(){ | ||
it('cy.readFile() - read a files contents', function () { | ||
// You can read a file and yield its contents | ||
@@ -1128,3 +1137,3 @@ // The filePath is relative to your project's root. | ||
// https://on.cypress.io/readfile | ||
cy.readFile('cypress.json').then(function(json) { | ||
cy.readFile('cypress.json').then(function (json) { | ||
expect(json).to.be.an('object') | ||
@@ -1135,3 +1144,3 @@ }) | ||
it('cy.writeFile() - write to a file', function(){ | ||
it('cy.writeFile() - write to a file', function () { | ||
// You can write to a file with the specified contents | ||
@@ -1142,7 +1151,7 @@ | ||
cy.request('https://jsonplaceholder.typicode.com/users') | ||
.then(function(response){ | ||
.then(function (response) { | ||
// https://on.cypress.io/writefile | ||
cy.writeFile('cypress/fixtures/users.json', response.body) | ||
}) | ||
cy.fixture('users').should(function(users){ | ||
cy.fixture('users').should(function (users) { | ||
expect(users[0].name).to.exist | ||
@@ -1155,6 +1164,6 @@ }) | ||
name: 'Jane', | ||
email: 'jane@example.com' | ||
email: 'jane@example.com', | ||
}) | ||
cy.fixture('profile').should(function(profile){ | ||
cy.fixture('profile').should(function (profile) { | ||
expect(profile.name).to.eq('Jane') | ||
@@ -1165,4 +1174,4 @@ }) | ||
context('Local Storage', function(){ | ||
beforeEach(function(){ | ||
context('Local Storage', function () { | ||
beforeEach(function () { | ||
cy.visit('http://localhost:8080/commands/local-storage') | ||
@@ -1174,5 +1183,5 @@ }) | ||
it('cy.clearLocalStorage() - clear all data in local storage', function(){ | ||
it('cy.clearLocalStorage() - clear all data in local storage', function () { | ||
// https://on.cypress.io/clearlocalstorage | ||
cy.get('.ls-btn').click().should(function(){ | ||
cy.get('.ls-btn').click().should(function () { | ||
expect(localStorage.getItem('prop1')).to.eq('red') | ||
@@ -1184,3 +1193,3 @@ expect(localStorage.getItem('prop2')).to.eq('blue') | ||
// clearLocalStorage() yields the localStorage object | ||
cy.clearLocalStorage().should(function(ls){ | ||
cy.clearLocalStorage().should(function (ls) { | ||
expect(ls.getItem('prop1')).to.be.null | ||
@@ -1192,3 +1201,3 @@ expect(ls.getItem('prop2')).to.be.null | ||
// **** Clear key matching string in Local Storage **** | ||
cy.get('.ls-btn').click().should(function(){ | ||
cy.get('.ls-btn').click().should(function () { | ||
expect(localStorage.getItem('prop1')).to.eq('red') | ||
@@ -1199,3 +1208,3 @@ expect(localStorage.getItem('prop2')).to.eq('blue') | ||
cy.clearLocalStorage('prop1').should(function(ls){ | ||
cy.clearLocalStorage('prop1').should(function (ls) { | ||
expect(ls.getItem('prop1')).to.be.null | ||
@@ -1207,3 +1216,3 @@ expect(ls.getItem('prop2')).to.eq('blue') | ||
// **** Clear key's matching regex in Local Storage **** | ||
cy.get('.ls-btn').click().should(function(){ | ||
cy.get('.ls-btn').click().should(function () { | ||
expect(localStorage.getItem('prop1')).to.eq('red') | ||
@@ -1214,3 +1223,3 @@ expect(localStorage.getItem('prop2')).to.eq('blue') | ||
cy.clearLocalStorage(/prop1|2/).should(function(ls){ | ||
cy.clearLocalStorage(/prop1|2/).should(function (ls) { | ||
expect(ls.getItem('prop1')).to.be.null | ||
@@ -1223,4 +1232,4 @@ expect(ls.getItem('prop2')).to.be.null | ||
context('Cookies', function(){ | ||
beforeEach(function(){ | ||
context('Cookies', function () { | ||
beforeEach(function () { | ||
Cypress.Cookies.debug(true) | ||
@@ -1235,3 +1244,3 @@ | ||
it('cy.getCookie() - get a browser cookie', function(){ | ||
it('cy.getCookie() - get a browser cookie', function () { | ||
// https://on.cypress.io/getcookie | ||
@@ -1244,3 +1253,3 @@ cy.get('#getCookie .set-a-cookie').click() | ||
it('cy.getCookies() - get browser cookies', function(){ | ||
it('cy.getCookies() - get browser cookies', function () { | ||
// https://on.cypress.io/getcookies | ||
@@ -1252,3 +1261,3 @@ cy.getCookies().should('be.empty') | ||
// cy.getCookies() yields an array of cookies | ||
cy.getCookies().should('have.length', 1).should( function(cookies) { | ||
cy.getCookies().should('have.length', 1).should(function (cookies) { | ||
@@ -1265,3 +1274,3 @@ // each cookie has these properties | ||
it('cy.setCookie() - set a browser cookie', function(){ | ||
it('cy.setCookie() - set a browser cookie', function () { | ||
// https://on.cypress.io/setcookie | ||
@@ -1276,3 +1285,3 @@ cy.getCookies().should('be.empty') | ||
it('cy.clearCookie() - clear a browser cookie', function(){ | ||
it('cy.clearCookie() - clear a browser cookie', function () { | ||
// https://on.cypress.io/clearcookie | ||
@@ -1291,3 +1300,3 @@ cy.getCookie('token').should('be.null') | ||
it('cy.clearCookies() - clear browser cookies', function(){ | ||
it('cy.clearCookies() - clear browser cookies', function () { | ||
// https://on.cypress.io/clearcookies | ||
@@ -1307,12 +1316,12 @@ cy.getCookies().should('be.empty') | ||
context('Spies, Stubs, and Clock', function(){ | ||
it('cy.spy() - wrap a method in a spy', function(){ | ||
context('Spies, Stubs, and Clock', function () { | ||
it('cy.spy() - wrap a method in a spy', function () { | ||
// https://on.cypress.io/spy | ||
cy.visit('http://localhost:8080/commands/spies-stubs-clocks') | ||
var obj = { | ||
foo () {} | ||
let obj = { | ||
foo () {}, | ||
} | ||
var spy = cy.spy(obj, 'foo').as('anyArgs') | ||
let spy = cy.spy(obj, 'foo').as('anyArgs') | ||
@@ -1325,11 +1334,11 @@ obj.foo() | ||
it('cy.stub() - create a stub and/or replace a function with a stub', function(){ | ||
it('cy.stub() - create a stub and/or replace a function with a stub', function () { | ||
// https://on.cypress.io/stub | ||
cy.visit('http://localhost:8080/commands/spies-stubs-clocks') | ||
var obj = { | ||
foo () {} | ||
let obj = { | ||
foo () {}, | ||
} | ||
var stub = cy.stub(obj, 'foo').as('foo') | ||
let stub = cy.stub(obj, 'foo').as('foo') | ||
@@ -1342,6 +1351,6 @@ obj.foo('foo', 'bar') | ||
it('cy.clock() - control time in the browser', function(){ | ||
it('cy.clock() - control time in the browser', function () { | ||
// create the date in UTC so its always the same | ||
// no matter what local timezone the browser is running in | ||
var now = new Date(Date.UTC(2017, 2, 14)).getTime() | ||
let now = new Date(Date.UTC(2017, 2, 14)).getTime() | ||
@@ -1355,6 +1364,6 @@ // https://on.cypress.io/clock | ||
it('cy.tick() - move time in the browser', function(){ | ||
it('cy.tick() - move time in the browser', function () { | ||
// create the date in UTC so its always the same | ||
// no matter what local timezone the browser is running in | ||
var now = new Date(Date.UTC(2017, 2, 14)).getTime() | ||
let now = new Date(Date.UTC(2017, 2, 14)).getTime() | ||
@@ -1372,13 +1381,13 @@ // https://on.cypress.io/tick | ||
context('Utilities', function(){ | ||
beforeEach(function(){ | ||
context('Utilities', function () { | ||
beforeEach(function () { | ||
cy.visit('http://localhost:8080/utilities') | ||
}) | ||
it('Cypress._.method() - call a lodash method', function(){ | ||
it('Cypress._.method() - call a lodash method', function () { | ||
// use the _.chain, _.map, _.take, and _.value functions | ||
// https://on.cypress.io/_ | ||
cy.request('https://jsonplaceholder.typicode.com/users') | ||
.then(function(response){ | ||
var ids = Cypress._.chain(response.body).map('id').take(3).value() | ||
.then(function (response) { | ||
let ids = Cypress._.chain(response.body).map('id').take(3).value() | ||
@@ -1389,5 +1398,5 @@ expect(ids).to.deep.eq([1, 2, 3]) | ||
it('Cypress.$(selector) - call a jQuery method', function(){ | ||
it('Cypress.$(selector) - call a jQuery method', function () { | ||
// https://on.cypress.io/$ | ||
var $li = Cypress.$('.utility-jquery li:first') | ||
let $li = Cypress.$('.utility-jquery li:first') | ||
@@ -1400,7 +1409,7 @@ cy.wrap($li) | ||
it('Cypress.moment() - format or parse dates using a moment method', function(){ | ||
it('Cypress.moment() - format or parse dates using a moment method', function () { | ||
// use moment's format function | ||
// https://on.cypress.io/cypress-moment | ||
// eslint-disable-next-line no-unused-vars | ||
var time = Cypress.moment().utc('2014-04-25T19:38:53.196Z').format('h:mm A') | ||
let time = Cypress.moment().utc('2014-04-25T19:38:53.196Z').format('h:mm A') | ||
@@ -1411,4 +1420,4 @@ cy.get('.utility-moment').contains('3:38 PM') | ||
it('Cypress.Blob.method() - blob utilities and base64 string conversion', function(){ | ||
cy.get('.utility-blob').then(function($div){ | ||
it('Cypress.Blob.method() - blob utilities and base64 string conversion', function () { | ||
cy.get('.utility-blob').then(function ($div) { | ||
// https://on.cypress.io/blob | ||
@@ -1418,5 +1427,5 @@ // https://github.com/nolanlawson/blob-util#imgSrcToDataURL | ||
return Cypress.Blob.imgSrcToDataURL('/assets/img/javascript-logo.png', undefined, 'anonymous') | ||
.then(function(dataUrl){ | ||
// create an <img> element and set its src to the dataUrl | ||
var img = Cypress.$('<img />', {src: dataUrl}) | ||
.then(function (dataUrl) { | ||
// create an <img> element and set its src to the dataUrl | ||
let img = Cypress.$('<img />', { src: dataUrl }) | ||
// need to explicitly return cy here since we are initially returning | ||
@@ -1428,3 +1437,3 @@ // the Cypress.Blob.imgSrcToDataURL promise to our test | ||
cy.get('.utility-blob img').click() | ||
.should('have.attr', 'src', dataUrl) | ||
.should('have.attr', 'src', dataUrl) | ||
}) | ||
@@ -1434,11 +1443,11 @@ }) | ||
it('new Cypress.Promise(function) - instantiate a bluebird promise', function(){ | ||
it('new Cypress.Promise(function) - instantiate a bluebird promise', function () { | ||
// https://on.cypress.io/promise | ||
var waited = false | ||
let waited = false | ||
function waitOneSecond(){ | ||
function waitOneSecond () { | ||
// return a promise that resolves after 1 second | ||
// eslint-disable-next-line no-unused-vars | ||
return new Cypress.Promise(function(resolve, reject){ | ||
setTimeout(function(){ | ||
return new Cypress.Promise(function (resolve, reject) { | ||
setTimeout(function () { | ||
// set waited to true | ||
@@ -1453,6 +1462,6 @@ waited = true | ||
cy.then(function(){ | ||
cy.then(function () { | ||
// return a promise to cy.then() that | ||
// is awaited until it resolves | ||
return waitOneSecond().then(function(str){ | ||
return waitOneSecond().then(function (str) { | ||
expect(str).to.eq('foo') | ||
@@ -1466,10 +1475,10 @@ expect(waited).to.be.true | ||
context('Cypress.config()', function(){ | ||
beforeEach(function(){ | ||
context('Cypress.config()', function () { | ||
beforeEach(function () { | ||
cy.visit('http://localhost:8080/cypress-api/config') | ||
}) | ||
it('Cypress.config() - get and set configuration options', function(){ | ||
it('Cypress.config() - get and set configuration options', function () { | ||
// https://on.cypress.io/config | ||
var myConfig = Cypress.config() | ||
let myConfig = Cypress.config() | ||
@@ -1497,4 +1506,4 @@ expect(myConfig).to.have.property('animationDistanceThreshold', 5) | ||
context('Cypress.env()', function(){ | ||
beforeEach(function(){ | ||
context('Cypress.env()', function () { | ||
beforeEach(function () { | ||
cy.visit('http://localhost:8080/cypress-api/env') | ||
@@ -1506,3 +1515,3 @@ }) | ||
// https://on.cypress.io/environment-variables | ||
it('Cypress.env() - get environment variables', function(){ | ||
it('Cypress.env() - get environment variables', function () { | ||
// https://on.cypress.io/env | ||
@@ -1512,3 +1521,3 @@ // set multiple environment variables | ||
host: 'veronica.dev.local', | ||
api_server: 'http://localhost:8888/v1/' | ||
api_server: 'http://localhost:8888/v1/', | ||
}) | ||
@@ -1529,4 +1538,4 @@ | ||
context('Cypress.Cookies', function(){ | ||
beforeEach(function(){ | ||
context('Cypress.Cookies', function () { | ||
beforeEach(function () { | ||
cy.visit('http://localhost:8080/cypress-api/cookies') | ||
@@ -1536,3 +1545,3 @@ }) | ||
// https://on.cypress.io/cookies | ||
it('Cypress.Cookies.debug() - enable or disable debugging', function(){ | ||
it('Cypress.Cookies.debug() - enable or disable debugging', function () { | ||
Cypress.Cookies.debug(true) | ||
@@ -1549,3 +1558,3 @@ | ||
it('Cypress.Cookies.preserveOnce() - preserve cookies by key', function(){ | ||
it('Cypress.Cookies.preserveOnce() - preserve cookies by key', function () { | ||
// normally cookies are reset after each test | ||
@@ -1560,7 +1569,7 @@ cy.getCookie('fakeCookie').should('not.be.ok') | ||
it('Cypress.Cookies.defaults() - set defaults for all cookies', function(){ | ||
it('Cypress.Cookies.defaults() - set defaults for all cookies', function () { | ||
// now any cookie with the name 'session_id' will | ||
// not be cleared before each new test runs | ||
Cypress.Cookies.defaults({ | ||
whitelist: 'session_id' | ||
whitelist: 'session_id', | ||
}) | ||
@@ -1570,4 +1579,4 @@ }) | ||
context('Cypress.dom', function(){ | ||
beforeEach(function(){ | ||
context('Cypress.dom', function () { | ||
beforeEach(function () { | ||
cy.visit('http://localhost:8080/cypress-api/dom') | ||
@@ -1577,5 +1586,5 @@ }) | ||
// https://on.cypress.io/dom | ||
it('Cypress.dom.isHidden() - determine if a DOM element is hidden', function(){ | ||
var hiddenP = Cypress.$('.dom-p p.hidden').get(0) | ||
var visibleP = Cypress.$('.dom-p p.visible').get(0) | ||
it('Cypress.dom.isHidden() - determine if a DOM element is hidden', function () { | ||
let hiddenP = Cypress.$('.dom-p p.hidden').get(0) | ||
let visibleP = Cypress.$('.dom-p p.visible').get(0) | ||
@@ -1588,4 +1597,4 @@ // our first paragraph has css class 'hidden' | ||
context('Cypress.Server', function(){ | ||
beforeEach(function(){ | ||
context('Cypress.Server', function () { | ||
beforeEach(function () { | ||
cy.visit('http://localhost:8080/cypress-api/server') | ||
@@ -1598,3 +1607,3 @@ }) | ||
// https://on.cypress.io/cypress-server | ||
it('Cypress.Server.defaults() - change default config of server', function(){ | ||
it('Cypress.Server.defaults() - change default config of server', function () { | ||
Cypress.Server.defaults({ | ||
@@ -1604,5 +1613,5 @@ delay: 0, | ||
// eslint-disable-next-line no-unused-vars | ||
whitelist: function(xhr){ | ||
whitelist (xhr) { | ||
// handle custom logic for whitelisting | ||
} | ||
}, | ||
}) | ||
@@ -1609,0 +1618,0 @@ }) |
{ | ||
"name": "cypress-example-kitchensink", | ||
"version": "0.8.1", | ||
"version": "0.8.2", | ||
"description": "This is an example app used to showcase Cypress.io testing. For a full reference of our documentation, go to docs.cypress.io", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"start": "http-server app -c-1", | ||
"start-ci": "http-server app -c-1 --silent", | ||
"start:ci": "http-server app -c-1 --silent", | ||
"dev": "npm start -- -o", | ||
@@ -14,5 +14,14 @@ "release": "releaser", | ||
"pretest": "npm run lint", | ||
"lint": "eslint --fix cypress/**/*.js", | ||
"lint": "eslint --fix cypress/**/*.js app/assets/js/scripts.js", | ||
"colon:names": "colon-names", | ||
"e2e": "cypress run", | ||
"test-ci": "run-p --race start-ci e2e" | ||
"e2e:chrome": "cypress run --browser chrome", | ||
"e2e:record": "cypress run --record", | ||
"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", | ||
"cy:verify": "cypress verify", | ||
"cy:version": "cypress version", | ||
"cy:run": "cypress run", | ||
"cy:open": "cypress open" | ||
}, | ||
@@ -34,7 +43,11 @@ "repository": { | ||
"devDependencies": { | ||
"@cypress/releaser": "0.2.1", | ||
"cypress": "1.0.2", | ||
"@cypress/releaser": "0.2.2", | ||
"colon-names": "1.0.0", | ||
"cypress": "1.1.2", | ||
"eslint": "^4.0.0", | ||
"eslint-plugin-cypress": "2.0.1", | ||
"eslint-plugin-cypress-dev": "1.1.1", | ||
"eslint-plugin-mocha": "4.11.0", | ||
"stop-build": "^1.1.0" | ||
} | ||
} |
@@ -1,28 +0,11 @@ | ||
# 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) [![Travis CI](https://travis-ci.org/cypress-io/cypress-example-kitchensink.svg?branch=master)](https://travis-ci.org/cypress-io/cypress-example-kitchensink) [![Cypress Dashboard](https://img.shields.io/badge/cypress-dashboard-brightgreen.svg)](https://dashboard.cypress.io/#/projects/4b7344/runs) | ||
# 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) [![Travis CI](https://travis-ci.org/cypress-io/cypress-example-kitchensink.svg?branch=master)](https://travis-ci.org/cypress-io/cypress-example-kitchensink) [![Cypress Dashboard](https://img.shields.io/badge/cypress-dashboard-brightgreen.svg)](https://dashboard.cypress.io/#/projects/4b7344/runs) [![Build status](https://badge.buildkite.com/d1bd1f093d97de34475da7d545c80eb2be9749eefe1c7133f0.svg)](https://buildkite.com/cypress-io/cypress-example-kitchensink) [![Greenkeeper badge](https://badges.greenkeeper.io/cypress-io/cypress-example-kitchensink.svg)](https://greenkeeper.io/) | ||
![kitchensink](https://cloud.githubusercontent.com/assets/1268976/14084252/e309e370-f4e7-11e5-9562-24f516563ac9.gif) | ||
This is an example app used to showcase [Cypress.io](https://www.cypress.io/) testing. The application utilizes every command available in Cypress for demonstration purposes. Additionally this example app is configured to run tests in Travis CI and CircleCI. The [tests](https://github.com/cypress-io/cypress-example-kitchensink/blob/master/cypress/integration/example_spec.js) are also heavily commented. For a full reference of our documentation, go to [docs.cypress.io](https://docs.cypress.io/). | ||
This is an example app used to showcase [Cypress.io](https://www.cypress.io/) testing. The application uses every API command in Cypress for demonstration purposes. Additionally this example app is configured to run tests in various CI platforms. The [tests](https://github.com/cypress-io/cypress-example-kitchensink/blob/master/cypress/integration/example_spec.js) are also heavily commented. For a full reference of our documentation, go to [docs.cypress.io](https://docs.cypress.io/). | ||
To see the kitchen sink application, visit [example.cypress.io](https://example.cypress.io/). | ||
## Features: | ||
- Querying | ||
- Traversal | ||
- Actions | ||
- Viewport | ||
- Navigation | ||
- Aliasing | ||
- Waiting | ||
- Network Requests | ||
- Files | ||
- Local Storage | ||
- Cookies | ||
- Spies, Stubs & Clocks | ||
## Help + Testing | ||
The steps below will take you all the way through Cypress. It is assumed you have nothing installed except for node + git. | ||
**If you get stuck, here is more help:** | ||
@@ -33,8 +16,4 @@ | ||
### 1. Install Cypress | ||
### 1. Fork this repo | ||
[Follow these instructions to install Cypress.](https://on.cypress.io/guides/installing-and-running#section-installing) | ||
### 2. Fork this repo | ||
If you want to experiment with running this project in Continous Integration, you'll need to [fork](https://github.com/cypress-io/cypress-example-kitchensink#fork-destination-box) it first. | ||
@@ -64,10 +43,6 @@ | ||
### 3. Add the project to Cypress | ||
### 2. Install & write tests in Cypress | ||
[Follow these instructions to add the project to Cypress.](https://on.cypress.io/guides/installing-and-running#section-adding-projects) | ||
[Follow these instructions to install and write tests in Cypress.](https://on.cypress.io/installing-cypress) | ||
### 4. Run in Continuous Integration | ||
[Follow these instructions to run the tests in CI.](https://on.cypress.io/guides/continuous-integration#section-running-in-ci) | ||
## Contributing | ||
@@ -79,2 +54,5 @@ | ||
#### 0.8.2 - *(11/30/17)* | ||
- eslint tests and js script | ||
#### 0.8.1 - *(10/16/17)* | ||
@@ -81,0 +59,0 @@ - updated .prev html to match test |
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
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
2267926
58
8
2674
133