End-to-End Testing using Puppeteer and Lambda. Lambda executes every n minutes via Cloudwatch events. This was dicussed over two years ago
As developers we are committed to delivering a high level of product quality to our customers.
In the past, I have used Selenium for running end-to-end tests. Stability issues with that setup resulted led to my poor adoption.
Test like end-to-end (E2E) tests, take more time to author, but give you much more confidence that the application will work as the user expects, since they replicate scenarios similar to how a user would use the application in real life.
To make E2E testing an essential part of the developer workflow and help deliver a quality experience to our customers, we will focus on a few key principles:
- Make end-to-end tests simple to run and debug
- Push test failure notifications to our engineers
- Leverage open source libraries
- Push test reports to engineers
- Clearly highlight failures and suite stability through notifications and reporting
- Test failures to be actionable
- Make it as straightforward for new engineers to learn
- Run tests quickly and reliably
- Run as many test as we wanted in parallel
- Puppeteer is a Headless Chrome Node API, which controls a version of the Chrome browser.
- Built on top of the Chrome DevTools Protocol
- Event-driven architecture
- High quality documentation & strong community of maintenance
- Ability to test against different page viewports and network conditions
- We found that many of our bugs were non-browser specific. Given the other methods we currently use for catching browser-specific bugs (not writing browser-specific code, better linting, JavaScript and CSS polyfills, smoke-testing on other browsers we support), we felt comfortable with this decision. Additional considerations included estimating migration time and setting up training for engineers to adapt from Selenium.
To build this app, you need to be in this example's root folder. Then run the following:
npm install -g aws-cdk
npm install
npm run package
This will install the necessary CDK, then this example's dependencies, and then build your TypeScript files and your CloudFormation template, and zip the lambda handler code.
Run cdk deploy
. This will deploy / redeploy your Stack to your AWS Account.
After the deployment you will see the API's URL, which represents the url you can then use.
To see the Cloudformation template generated by the CDK, run cdk synth
, then check the output file in the "cdk.out" directory.