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.
Requirements: docker, terraform, nodejs >= 8
cd lambda
docker build . -t cypress-lambda
./deps.sh
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
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)
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.
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.