Fantastic quick start guide. We have been looking into doing this for Checkout for WooCommerce and this has inspired me to dig back in. I really want someone to create a browser add-on that records a browser session and stores it as a Cypress script because testing complex scenarios is a lot of tedious "Click here then here, ok now fill out each field in this long form"
Great introduction Peter, one note: you don't need any of cy.wait
there. Cypress will wait for the DOM element in the next command to become visible / clickable / typeable before proceeding, so no need to slow down your tests artificially.
Right you are! I thought there was a reason I had those wait()'s in there, I think I was remembering using Puppeteer and that being an issue. Cheers!
old testing habits die hard :)
Looks like a pretty cool testing solution. I've recently been using Ghostinspector.com for these purposes and it works great. The free tier allows up to 100 tests a month. They've got a browser extension that allows you to record a script which can be exported in Selenium format.
Hi Pete, Question from the back of the class: Have you worked through how to setup testing environments? Our use cases are pretty complex and involve configuring the plugin a certain way and then running a test. Thinking that we may have to do separate docker containers or something, but I know that will also have an impact if we want this to be part of an automated test suite at some point. Also wondering if you know if tests can be modular where say you have "Big Test Scenario A" and "Big Test Scenario B" and they both include a small "Test 2" as a component. Have you done anything like that? Clif
I'm also fairly new to Cypress testing, but I've done some work with Google's Puppeteer, which is essentially a JS wrapper for headless Chrome. Setting up the test environments is indeed the tricky part. In the beforeEach() and before() functions you can run any Node or CLI script. I actually do the following to set up the tests for our Find & Replace run: beforeEach( function() { //Need to restore DB before run cy.exec( 'cd ' + Cypress.env( "site1" ).path + '/db_backup && wp db import clean-db.sql' ).its( 'stdout' ).should( 'contain', 'Success' )//...}
Using cy.exec()
you can run anything you could run on the CLI. As far as actually spinning up servers or environments, this is where you'd do that. I just have a couple pre-configured sites set up locally that get wiped before the test run.
Hi Clif. We are working on a similar setup with docker to get our CI 100% complete. We are using WPengine, multisite, bitbucket pipelines, deploybot, and cypress. Were you able to have any success with Docker here? We are 90% there but would love a chat with someone who has been able to complete CI for WordPress with Docker and cypress.
Unfortunately I haven't had the time to see this through, so I don't have anything to help you here. Let me know if you get it working!
Hi @petertasker:disqus , This is very detailed informations , good to start, I'm new to cypress tool, How to upload the audio files , I'd noticed we have few issues . do you have any idea how to upload the audio files ? Issue details >>> https://github.com/cypress-io/cypress/issues/170
Hi Pete, Good article! I have a couple of questions for you: Does Cypress safari and Firefox support? And you don’t know why cypress is better than Codeceptjs (https://codecept.io/)? We chose Codeceptjs at work because it supports Puppeteer. And yet, Puppeteer already supports firefox. I have a short article on how to write a first test for a beginner using the CodeceptJS framework. https://medium.com/@vladimirbaginskiy/javascript-end-2-end-testing-for-mere-mortals-e055db5e80d4