paint-brush
No Tests? No Problem: Automating NodeJs Testingby@royaljain
109 reads

No Tests? No Problem: Automating NodeJs Testing

by Royal JainJune 27th, 2023
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Record and Replay is the lightweight solution for test automation. The value is the most prominent for teams that are still transitioning from mostly manual testing to include some automation in order to speed up testing and help integrate it earlier in the software development lifecycle.
featured image - No Tests? No Problem: Automating NodeJs Testing
Royal Jain HackerNoon profile picture


Record and Replay, otherwise known as codeless automation, is a way to run tests without programming knowledge. This is done using a tool, like CodeParrot, which allows you to record requests coming to your service.


You can then take this and rerun it with a click, making regression testing infinitely faster.


Record and Replay is the lightweight solution for test automation. The value is the most prominent for teams that are still transitioning from mostly manual testing to include some automation in order to speed up testing and help integrate it earlier in the software development lifecycle.

CodeParrot Node Js Setup

We'll use the repository https://github.com/Code-Parrot-ai/codeparrot-examples/ for this article. This repository shows an example of using CodeParrot for Nodejs with the express framework.

git clone https://github.com/Code-Parrot-ai/codeparrot-examples.git

cd nodejs-express
npm i

Phase I: Record

Run the npm 'record' script; all requests coming to this service will be recorded.

npm run record


Close the script. You can now go to the dashboard to generate unique requests on the dashboard https://dashboard.codeparrot.ai/dashboard. Select your service, and click on "Regenerate Unique Requests". You would be able to see the number of unique requests.

Phase II: Replay

The ideal way to run replay is through the GitHub CI App, but it can be run on a local machine using the 'replay' script.

npm run replay


You would be able to see the link to the change report in the log, like this:

Report will be available at: https://dashboard.codeparrot.ai/diff/nodejs-agent-for-internal@innate-actor-378220.iam.gserviceaccount.com/demo-calc-app/a60fbb9


The report might take up to a minute to generate; refresh the page if needed.