In this article, we talk about a basic example using Nodejs, Express, Docker, Jest and Sonarqube.
Using the wikipedia explanation “SonarQube is an open source platform developed by SonarSource for continuous code quality inspection, to perform automatic reviews with static code analysis to detect bugs, code odors and security vulnerabilities in over 20 languages. programming.”
For this tutorial, we’ll need:
With node and docker installed, let’s start the project
Creating project folder and browsing
mkdir NodeSonarExample
cd ./NodeSonarExample
Starting the project
npm init -y
In this session, we will install the dependencies and development dependencies for the project.
npm install — save express jest
npm install -D sonarqube-scanner jest-sonar-reporter supertest
Let’s start sonarqube by creating the docker-compose.sonar.yml file.
version: '3'
services:
sonarqube:
container_name: sonarqube
image: sonarqube:latest
ports:
- "9000:9000"
- "9092:9092"
and execute the file with the command:
docker-compose -f docker-compose.sonar.yml up -d
With sonarqube running, navigate to sonarqube address and authenticate using the default account
login: admin
password: admin
Authenticated, you will notice that there is no project pipeline created as shown in the image below
In this session, I will show the project structure, and all the code involved
#node #sonarqube #jest #nodejs #docker