No Tests? No Problem: Automating NodeJs Testing

Written by royaljain | Published 2023/06/27
Tech Story Tags: nodejs | test-automation | automated-testing | programming | testing | nodejs-tutorial | programming-tips | programming-tutorial

TLDRRecord 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.via the TL;DR App

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/[email protected]t.com/demo-calc-app/a60fbb9

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


Written by royaljain | Love creating digital products, here to learn and contribute.
Published by HackerNoon on 2023/06/27