Skip to content
Demo: running Cypress on AWS Lambda for maximally parallel e2e tests
JavaScript Shell HCL Dockerfile
Branch: master
Clone or download
Latest commit 4f6e4f1 Apr 9, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lambda typo Apr 8, 2019
.gitignore run each spec on Lambda in parallel Apr 8, 2019
README.md run each spec on Lambda in parallel Apr 8, 2019
index.js prettiar Apr 8, 2019
lambda.tf run each spec on Lambda in parallel Apr 8, 2019
package-lock.json run each spec on Lambda in parallel Apr 8, 2019
package.json run each spec on Lambda in parallel Apr 8, 2019

README.md

Cypress on AWS Lambda

This repo demonstrates how to run Cypress on AWS Lambda, executing each spec file in parallel.

The blog post, part 1 walks through the nitty gritty of getting a single Cypress spec running on Lambda (see branch part-1 for where this leaves off).

Part 2 contains details on invoking a Lambda function for each spec file and collecting the results in an mochawesome report.

Warning this is a prototype and it hasn't been battle-tested.

How do I use this?

Requirements: docker, terraform, nodejs >= 8

First build the image to gather dependencies

cd lambda
docker build . -t cypress-lambda

Extract dependencies from container

./deps.sh

Invoke Lambda handler locally

Verify that the handler invocation works when run locally with docker-lambda's: nodejs8.10 runtime, a dockerized replica of the AWS Lambda execution environment:

docker run --rm -v "$PWD":/var/task:ro lambci/lambda:nodejs8.10

Deploy it

Back in the project root:

touch lambda.zip
terraform init
terraform apply

(You'll have to change a couple things in lambda.tf for your situation, such as the s3 bucket name, which is globally unique)

Invoke it

In the project root, first:

npm install

And then:

npm test

This will invoke the deployed Lambda function once for each spec file, collect individual mochawesome JSON reports for each Lambda invocation, merge together the JSON reports, and produce a single mochawesome HTML report.

Use your own tests

So right now this is using the cypress kitchensink example; you'll want to put your own tests in lambda/cypress/integration and then go through all the steps above again.

You can’t perform that action at this time.