Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
43dbcd5
Initial commit
Ngwerume Sep 29, 2023
5ba1098
Coverage testing
Ngwerume Sep 29, 2023
da41266
Coverage testing
Ngwerume Sep 29, 2023
bea76e7
Coverage testing
Ngwerume Sep 29, 2023
39eac87
Coverage testing
Ngwerume Sep 29, 2023
674d14f
Coverage testing
Ngwerume Sep 29, 2023
6007e96
Coverage testing
Ngwerume Sep 29, 2023
810fc4b
Coverage testing
Ngwerume Sep 29, 2023
d730a1f
Coverage testing
Ngwerume Sep 29, 2023
b0bbf20
Coverage testing
Ngwerume Sep 29, 2023
652fa18
creating reports with errors
Ngwerume Sep 29, 2023
9477391
further tests
Ngwerume Sep 29, 2023
e48395f
fixed undefined var
Ngwerume Sep 29, 2023
3f3196d
fixed undefined var
Ngwerume Sep 29, 2023
1272ddb
fixed undefined var
Ngwerume Sep 29, 2023
29a6af0
fixed undefined var
Ngwerume Sep 29, 2023
7ab845b
fixed undefined var
Ngwerume Sep 29, 2023
12652a7
fixed a few more things for the example
Ngwerume Sep 29, 2023
2857c92
fixed a few more things for the example
Ngwerume Sep 29, 2023
7c3ab8e
fixed a few more things for the example
Ngwerume Sep 29, 2023
2064d57
fixed a few more things for the example
Ngwerume Sep 29, 2023
a95ee46
fixed a few more things for the example
Ngwerume Sep 29, 2023
6694490
resolving empty coverage
Ngwerume Sep 29, 2023
3afa9c9
resolving empty coverage
Ngwerume Sep 29, 2023
5ba770f
resolving empty coverage
Ngwerume Sep 29, 2023
2a04603
resolving empty coverage
Ngwerume Sep 29, 2023
f517f7f
resolving empty coverage
Ngwerume Sep 29, 2023
53a89a8
resolving empty coverage
Ngwerume Sep 29, 2023
48bcf71
resolving empty coverage
Ngwerume Sep 29, 2023
6ef048c
resolving empty coverage
Ngwerume Sep 29, 2023
a598235
resolving empty coverage
Ngwerume Sep 29, 2023
0a2e832
resolving empty coverage more
Ngwerume Sep 29, 2023
4b84383
resolving empty coverage more
Ngwerume Sep 29, 2023
6ac4986
resolving empty coverage more
Ngwerume Sep 29, 2023
bfac8f7
resolving empty coverage more
Ngwerume Sep 29, 2023
33c19ec
resolving empty coverage more
Ngwerume Sep 29, 2023
f64ae13
resolving empty coverage more
Ngwerume Sep 29, 2023
99d4230
resolving empty coverage more
Ngwerume Sep 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
env: {
node: true,
es6: true,
jest: true,
},
extends: ['eslint:recommended'],
plugins: ['jest'],
rules: {
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/valid-expect': 'error',
},
};
56 changes: 56 additions & 0 deletions .github/workflows/codacy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Client Side Tools and Coverage

on:
push:
branches: [ '*' ]
pull_request:
branches: [ '*' ]
workflow_dispatch:

jobs:
build:
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: '18' # Choose your Node.js version

- name: Run Codacy Analysis CLI with Docker (optional)
run: |
export CODACY_CODE=$GITHUB_WORKSPACE
docker run \
--rm=true \
--env CODACY_CODE="$CODACY_CODE" \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume "$CODACY_CODE":"$CODACY_CODE" \
--volume /tmp:/tmp \
codacy/codacy-analysis-cli \
analyze --tool eslint --upload --project-token ${{ secrets.CODACY_PROJECT_TOKEN }} --max-allowed-issues 99999 --commit-uuid $GITHUB_SHA

- name: Install dependencies
run: |
npm install -g nyc # Install Istanbul (nyc) for code coverage
npm install # Install project dependencies
npm install --save-dev nyc
npm install --save-dev chai
npm install --save-dev blanket
npm install --save-dev mocha
npm install --save-dev mocha-lcov-reporter

- name: Run tests and collect coverage
run: |
# Replace with the actual command to run your tests
npm test
continue-on-error: true

- name: Upload coverage report to Codacy
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
run: |
bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r $GITHUB_WORKSPACE/lcov.info
continue-on-error: true
21 changes: 21 additions & 0 deletions __tests__/main.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { addNumbers, subtractNumbers } = require('../main');
const { expect } = require('chai');

// Describe a test suite for main.js
describe('Main Module', () => {
// Test the addNumbers function
describe('addNumbers', () => {
it('should add two numbers correctly', () => {
const result = addNumbers(5, 3);
expect(result).to.equal(8);
});
});

// Test the subtractNumbers function
describe('subtractNumbers', () => {
it('should subtract two numbers correctly', () => {
const result = subtractNumbers(10, 3);
expect(result).to.equal(7);
});
});
});
9 changes: 9 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// jest.config.js

module.exports = {
testEnvironment: 'node',
coverageProvider: 'v8', // Use Istanbul (nyc) for code coverage
collectCoverage: true,
collectCoverageFrom: ['**/*.js'],
};

37 changes: 37 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// This is the main JavaScript file of your sample project.

// Import the utility functions from util.js
const { add, subtract } = require('./util');

// Function to add two numbers
function addNumbers(a, b) {
return add(a, b);
}

// Function to subtract two numbers
function subtractNumbers(a, b) {
return subtract(a, b);
}

// Removed the unused variable
// const unusedVariable = 'This variable is not used';

// Removed the missing semicolon
const missingSemicolon = 'This line is missing a semicolon';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Codacy found a minor Code Style issue: 'missingSemicolon' is assigned a value but never used.

The code is flagged by ESLint because it contains a variable missingSemicolon that is assigned a value but never used. To fix this issue, you can either remove the variable assignment or use the variable somewhere in your code.

Suggested change
const missingSemicolon = 'This line is missing a semicolon';
// Removed the unused variable
// const missingSemicolon = 'This line is missing a semicolon';

This will remove the unused variable and resolve the ESLint error.


This comment was generated by an experimental AI tool.


// Removed the undefined variable usage
// console.log(undefinedVariable);

// Removed the attempt to reassign a constant
// const constantValue = 42;
// constantValue = 43;

// Removed the missing function argument
// function missingArgument(arg1, arg2) {
// return arg1 + arg2;
// }

module.exports = {
addNumbers,
subtractNumbers,
};
Loading