{"id":15012830,"url":"https://github.com/paulogoncalvesbh/running-playwright-on-aws-lambda","last_synced_at":"2025-04-05T22:05:30.500Z","repository":{"id":39602538,"uuid":"398126831","full_name":"PauloGoncalvesBH/running-playwright-on-aws-lambda","owner":"PauloGoncalvesBH","description":"Running hundreds of Playwright E2E tests in a few seconds with AWS Lambda","archived":false,"fork":false,"pushed_at":"2023-07-15T01:05:45.000Z","size":7446,"stargazers_count":405,"open_issues_count":1,"forks_count":46,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-04-05T22:05:25.606Z","etag":null,"topics":["lambda-functions","playwright","serverless"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PauloGoncalvesBH.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-20T02:01:35.000Z","updated_at":"2025-04-02T11:56:26.000Z","dependencies_parsed_at":"2024-12-15T19:11:38.557Z","dependency_job_id":"d16ef197-c3ac-491a-93f1-81a4eb4bad78","html_url":"https://github.com/PauloGoncalvesBH/running-playwright-on-aws-lambda","commit_stats":{"total_commits":16,"total_committers":3,"mean_commits":5.333333333333333,"dds":0.375,"last_synced_commit":"57ea9e56a07b6dcf9f2ffee5f47f51962dde32e4"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PauloGoncalvesBH%2Frunning-playwright-on-aws-lambda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PauloGoncalvesBH%2Frunning-playwright-on-aws-lambda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PauloGoncalvesBH%2Frunning-playwright-on-aws-lambda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PauloGoncalvesBH%2Frunning-playwright-on-aws-lambda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PauloGoncalvesBH","download_url":"https://codeload.github.com/PauloGoncalvesBH/running-playwright-on-aws-lambda/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406085,"owners_count":20933803,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lambda-functions","playwright","serverless"],"created_at":"2024-09-24T19:43:17.636Z","updated_at":"2025-04-05T22:05:30.483Z","avatar_url":"https://github.com/PauloGoncalvesBH.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Running hundreds of Playwright tests in a few seconds with AWS Lambda\n\n\u003cdiv align=\"center\"\u003e\n\u003cb\u003e\u003ci\u003eGive the \u003ca href=\"https://github.com/PauloGoncalvesBH/running-playwright-on-aws-lambda\"\u003erepository\u003c/a\u003e a star ⭐, it encourages me to create advanced software quality content 100% free\u003c/i\u003e\u003c/b\u003e\n\u003c/div\u003e\n\u003cbr\u003e\n\nThis project has a playwright implementation so that it is consumed via AWS Lambda, allowing to parallelize the execution of all files and making the execution much faster.\n\nThe success of this implementation demonstrates that, in scenarios where E2E testing is needed to validate critical behaviors that are not possible in another type of test, it is possible to use AWS Lambda to run this same test on all Pull Requests, not just a few times in day.\n\n\u003e _**Note:** This project was created as a result of study. Identify whether the parallelism presented here suits your case._\n\n## Result\n\nWith playwright on serverless it was possible to run 110 files parallelized, with 221 tests, in less than 25 seconds.\nThis same test running without parallelization would take 23 minutes. \n\n\u003e To see the execution in detail, you can access the [pipeline log by clicking here](https://github.com/PauloGoncalvesBH/running-playwright-on-aws-lambda/actions/workflows/test-serverless.yml).\n\nThe gif below demonstrates the execution:\n\n\u003cp align=\"center\"\u003e\n \u003cimg alt=\"Gif showing playwright execution\" src=\"./.github/running-playwright-serverless.gif\"\u003e\n\u003c/p\u003e\n\n## Pricing\n\nRunning hundreds of Lambda functions that last a few seconds has little impact on the final cost. To implement this parallelism in your project, perform the price calculation.\n\nAWS Lambda Price:\n\n\u003e The AWS Lambda free usage tier includes 1M free requests per month and 400,000 GB-seconds of compute time per month.\n\nSource: https://aws.amazon.com/lambda/pricing/\n\n## Application diagram\n\n\u003cp align=\"center\"\u003e\n \u003cimg alt=\"Diagram\" src=\"./.github/Playwright-serverless.png\"\u003e\n\u003c/p\u003e\n\n## CloudWatch metrics\n\nBelow are some important CloudWatch metrics.\n\n110 lambda functions were invoked, however my account has a limit of 50 parallel executions, which made the total execution double in time. \n\nThe average time that a lambda function takes to run is 7 seconds, which is less than the total of 23 seconds that takes to run the test.\n\n**However 23 seconds is a quiet time to wait when running an E2E test in a pipeline. I think we both agree that it's better than 23 minutes.**\n\n### Parallel executions\n\nLimited to 50.\n\n\u003cp align=\"center\"\u003e\n \u003cimg alt=\"Parallel runs limited to 50\" src=\"./.github/concurrent-executions-lambda.png\"\u003e\n\u003c/p\u003e\n\n### Invocations\n\n1 invocation per test file in [./tests/E2E](./tests/E2E).\n\n\u003cp align=\"center\"\u003e\n \u003cimg alt=\"Number of calls equal to 110, 1 per test file\" src=\"./.github/invocations-lambda.png\"\u003e\n\u003c/p\u003e\n\n### Duration\n\nThe longest running lambda function was 10.2 seconds, less than half of the total execution time of all functions.\n\nWith a higher concurrent execution we would have better results in total time.\n\n\u003cp align=\"center\"\u003e\n \u003cimg alt=\"Duration showing the longest lambda was 10.2 seconds\" src=\"./.github/duration-lambda.png\"\u003e\n\u003c/p\u003e\n\n## More information\n\n\u003e To understand how tests are run and AWS Lambda is built I recommend accessing the pipelines in [./.github/workflows/](./.github/workflows/) and the [Makefile](./Makefile).\n\n### Deploying at AWS Lambda\n\n1. Install serverless globally:\n\n```sh\nnpm install --global serverless@3.X\n```\n\n2. Create AWS Acess keys: https://www.serverless.com/framework/docs/providers/aws/guide/credentials/#creating-aws-access-keys\n\n3. Configure the Serverless Framework CLI to use AWS access keys\n\n```sh\nserverless config credentials \\\n  --provider aws \\\n  --key \u003cAWS_ACCESS_KEY_ID\u003e \\\n  --secret \u003cAWS_SECRET_ACCESS_KEY\u003e\n```\n\n\u003e More at: https://www.serverless.com/framework/docs/providers/aws/cli-reference/config-credentials#configure-the-default-profile\n\n4. And, finally, deploy the application at AWS Lambda:\n\n```sh\nmake deploy\n```\n\n### Run tests at AWS Lambda\n\nAfter deploying run the tests using the following command:\n\n```sh\nmake test-serverless\n```\n\n### Run locally (without using AWS Lambda)\n\nAcess the directory [./tests](./tests) and execute:\n\n```sh\nnpm ci\n```\n\nRun the test with:\n\n```sh\nnpm test\n```\n\n___\n\n[LICENSE GNU General Public License v3.0](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulogoncalvesbh%2Frunning-playwright-on-aws-lambda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaulogoncalvesbh%2Frunning-playwright-on-aws-lambda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulogoncalvesbh%2Frunning-playwright-on-aws-lambda/lists"}