{
"cypress": {
"testFolder": "app/test/spec",
"fixturesFolder": "app/test/spec/_fixtures",
"supportFolder": "app/test/spec/_support",
"viewportWidth": 1300,
"viewportHeight": 660
}
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe("PieChopper", function(){ | |
| beforeEach(function(){ | |
| // visit our local server running the application | |
| // | |
| // visiting before each test ensures the app | |
| // gets reset to a clean state | |
| // | |
| // https://on.cypress.io/api/visit | |
| cy.visit("http://localhost:8080") | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $Cypress.register "Querying", (Cypress, _, $) -> | |
| priorityElement = "input[type='submit'], button, a, label" | |
| $expr = $.expr[":"] | |
| $contains = $expr.contains | |
| restoreContains = -> | |
| $expr.contains = $contains |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it("infinitely loops", function(){ | |
| var loop = function(){ | |
| return cy.visit("something").get("whatever").do().something().else().then(function(){ | |
| return loop() | |
| }) | |
| } | |
| return loop() | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Cypress.addDualCommand({ | |
| contains: function(subject, filter, text, options) { | |
| var checkToAutomaticallyRetry, getErr, getFirstDeepestElement, getOpts, getPhrase, onConsole, resolveElements, selector, setEl; | |
| if (options == null) { | |
| options = {}; | |
| } | |
| if (subject && !Cypress.Utils.hasElement(subject)) { | |
| subject = null; | |
| } | |
| switch (false) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Cypress.addChildCommand("arrowdown", function($el){ | |
| var evt = new Event("keydown", { | |
| bubbles: true, | |
| cancelable: true, | |
| altKey: false, | |
| ctrlKey: false, | |
| metaKey: false, | |
| shiftKey: false, | |
| location: 0, | |
| charCode: 0, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cy | |
| .get("ul[class='nav menu'] a").then(function($a){ | |
| var hrefs = $a.map(function(i, el){ | |
| return Cypress.$(el).attr("href") | |
| }).get() | |
| hrefs.forEach(function(href){ | |
| cy.visit("http://your.url" + href).should("not.contain", "your 404 message") | |
| // you might also try this |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // if you open your chrome dev tools | |
| // you'll see it log out the performance | |
| // of each iterating in the console | |
| var array = Array(100) | |
| console.time("var") | |
| for (i = 0; i < array.length; i++) { | |
| var e = array[i] | |
| for (j = 0; j < array.length; j++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| chalk = require("chalk") | |
| asciify = require("asciify") | |
| asteriks = Array(90).join("*") | |
| log = { | |
| newLine: (num = 1) -> | |
| n = Array(num).join("\n") | |
| console.log(n) | |
| } |
Example
/*
* In window A's scripts, with A being on <http://example.com:8080>:
*/
var popup = window.open(...popup details...);
// When the popup has fully loaded, if not blocked by a popup blocker: