diazamaliana / angular-sonarqube-integration-test

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Angular Sonarqube Integration Test

This is a mock boilerplate for Angular and SonarQube integration.

Development environment

  • Angular CLI version 12.2.8
  • SonarQube version 9.1
  • Sonar-scanner version 3.1.0
  • Other related libraries are available to see on package.json

Scripts available

Generator

Please use Angular CLI generator scripts for generating all boilerplates. For generating component inside a module, please use --module script followed by module name, example:

ng generate component core/components/component-name --module core

Run development server

Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Run code formatter check

Run npm run prettier:check to check if all files passed the style convention.

Run build

Run ng build to build the project. The build artifacts will be stored in the dist/ directory. Coverage report will be generated in the project's root file.

Run unit tests

Run ng test --code-coverage to execute the unit tests via Karma while also generating code coverage for creating SonarQube report.

Run sonar scanner

Run npm run sonar to scan all test report and send it to your local SonarQube projects.

Local SonarQube integration

This project is developed with SonarQube integration to check unit test coverage. To integrate the project with your local SonarQube, change project key, project name, host url value in sonar-scanner.properties file according to your own SonarQube project. If there is a requirement to login, add your project token into the properties file.

# default port is 9000, change it if you use different port
sonar.host.url=http://localhost:9000

# can be seen from SonarQube project information
# by default, project key and name are matched with repository name
sonar.projectKey=angular-sonarqube-integration-test
sonar.projectName=angular-sonarqube-integration-test

# must be the same username and password of your account
# change login value with token and remove password if you want to use token
sonar.login=admin
sonar.password=admin

Husky config

Utilizing husky, this project encourages developer to only commit a clean code. It means the code has to be tested. The code should pass lint and karma test first (also generating code coverage files) before it can be commited.

About


Languages

Language:TypeScript 70.4%Language:JavaScript 15.0%Language:SCSS 10.9%Language:HTML 3.7%