DEV Community

Cover image for No tests? No problem: Automating NodeJs testing
Royal Jain
Royal Jain

Posted on

No tests? No problem: Automating NodeJs testing

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, that 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 example of using CodeParrot for nodejs language with express framework.

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

cd nodejs-express
npm i
Enter fullscreen mode Exit fullscreen mode

Phase I: Record

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

npm run record
Enter fullscreen mode Exit fullscreen mode

Close the script. You can now go to 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 number of unique requests.

Phase II: Replay

Ideal way to run replay is through Github CI App, but can be run on local machine using the 'replay' script

npm run replay
Enter fullscreen mode Exit fullscreen mode

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

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

Report might take upto a minute to generate, refresh page if needed.

Top comments (0)