Skip to content

Commit

Permalink
Adding Test Coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielDushime committed May 21, 2024
1 parent d9ed712 commit 520090e
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 2 deletions.
16 changes: 15 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
version: 2.1

orbs:
node: circleci/[email protected]

jobs:
build:
executor:
name: node/default
steps:
- checkout
- node/install-packages
- run: npm test
- run:
name: Run tests and generate coverage report
command: npm run test:coverage
- run:
name: Install CodeClimate Test Reporter
command: npm install -g codeclimate-test-reporter
- run:
name: Upload coverage to CodeClimate
command: |
codeclimate-test-reporter < coverage/lcov.info
environment:
CC_TEST_REPORTER_ID: $CC_TEST_REPORTER_ID

workflows:
version: 2
build-deploy:
Expand Down
32 changes: 32 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: "2"
checks:
argument_count:
enabled: true
file_lines:
enabled: true
method_count:
enabled: true
return_count:
enabled: true

exclude_paths:
- "node_modules/**"
- "coverage/**"

engines:
eslint:
enabled: true
config:
extensions:
- .js
- .jsx

ratings:
paths:
- "**.js"
- "**.jsx"

test_reporter:
id: "cc-test-reporter"
coverage_file:
- "coverage/lcov.info"
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test Coverage

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16'

- name: Install dependencies
run: npm install

- name: Run tests
run: npm run test

- name: Upload coverage to CodeClimate
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: |
npm install -g codeclimate-test-reporter
codeclimate-test-reporter < coverage/lcov.info
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<div style="display: flex; justify-content: center;" align="center">
<img src="https://codecov.io/gh/atlp/e-commerce-furebo-32-bn/branch/main/graph/badge.svg?token=25aecf2d-ee44-4ac0-9f91-9f9c38ed5412" alt="Codecov" width="50%">
<img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/atlp/e-commerce-furebo-32-bn/job.yaml" width="50%">
</div>
</div>
[![Maintainability](https://api.codeclimate.com/v1/badges/b8b4783a32fb76cb4953/maintainability)](https://codeclimate.com/github/atlp-rwanda/e-commerce-furebo-32-bn/maintainability)

[![Test Coverage](https://api.codeclimate.com/v1/badges/b8b4783a32fb76cb4953/test_coverage)](https://codeclimate.com/github/atlp-rwanda/e-commerce-furebo-32-bn/test_coverage)
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ module.exports = {
resetMocks: true,
restoreMocks: true,
clearMocks: true,
collectCoverage: true,
coverageReporters: ["lcov", "text"],
coverageDirectory: "coverage",
};

0 comments on commit 520090e

Please sign in to comment.