Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Run Cypress Tests without the UI


    The Cypress UI is a great way to work through individual tests and while TDD-ing new features, but it isn’t ideal for running large test suites or for running on a CI server. In this lesson, we’ll add an npm script to run all of our tests without the UI and look at the results of a full test run.



    Become a Member to view code

    You must be a Pro Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    orLog In




    Instructor: The Cypress UI is a great tool for building our application in a test-driven style. It gives us really nice capabilities when we need to debug our application.

    The UI isn't a great option for running an entire suite of tests. The overhead that makes all of that utility possible can really slow things down for a large suite of tests. The UI isn't going to be seen when running on a CI server, anyway.

    Let's see how we can do a full test run without launching the Cypress Test Runner UI. We'll add a new command to our npm scripts. Right under our existing Cyprus command, we'll create a new one. We'll make it cypress:all.

    Instead of cypress open, this one is going to run cypress run. I'll save this.

    Now I'm going to open up a terminal. In one tab of my terminal, I'm going to start my application because we still need the application running to test against. I'll do that with npm run dev.

    This'll do a webpack build and start the JSON server. Then in a second tab, I'll do npm run cypress:all.

    We'll see that it's going to run through our entire suite of tests. At the end, we get a nice summary of our test run. We're even going to get a video of our test run that we can watch.

    We'll see that the video's been saved in our project. I can open that up. If we run through the video, we'll see that if something were to go wrong, we have a nice view into our test.

    We can actually come in here, take a look, see if we can figure out what the problem was, and then maybe jump back into the UI to do a little bit of investigation.