All the Software developers of Netspective Communications LLC across all the projects
must have a consistent code coverage process.
Controls
All are required to adhere to the coverage tool that aligns with their development technology listed below.
Language / Framework | Coverage Tool | Remarks |
---|---|---|
Node.js | Jest | The same can be used for Node.js, TypeScript Projects |
ReactJS | Jest, React Testing Library | We use jest and react testing library to unit test react components |
ReactJS
All developers who use ReactJS as programming language must use Jest and React Testing Library as the coverage tools. [FII-CQI-100-CCP-01] All developers who use ReactJS as programming language must follow Code Unit testing Policy before going to the steps below.
-
Ensure to execute the below command in the CLI to install packages.
npm install --save-dev jest @types/jest @testing-library/react @testing-library/jest-dom jest-environment-jsdom jest-junit
[FII-CQI-100-CCP-02]
-
Ensure to add the below provided content to package.json to run coverage in the project using the ‘npm run test’ and ‘npm run test
’ command"scripts": { "test:coverage": "jest --coverage", "test:ci": "npm run test -- --testResultsProcessor=\"jest-junit\" --watchAll=false --ci --coverage", },
[FII-CQI-100-CCP-03]
-
Ensure
npm run test:coverage
command will run for coverage whole project and generate coverage result in'/coverage/lcov-report'
folder. [FII-CQI-006-CCP-04] -
Ensure to add and modify the configuration file
jest.config.cjs
and ensure rules must matches Deno formatting rule.module.exports = { {/* ... */} coverageReporters: ["lcov", "text"], };
[FII-CQI-100-CCP-05]
-
Ensure
npm run test:ci
command will run for coverage whole project and generates a report filejunit.xml
in project root. [FII-CQI-100-CCP-06] -
Ensure to add
junit.xml
in the.gitignore
file. [FII-CQI-100-CCP-07] -
All React developers must ensure they are following React reference Project for React code quality.
Evidence
ReactJS
[FII-CQI-006-CCP-03] Execute the below duckdb query in a CLI to verify package.json contains required packages.
duckdb -s "SELECT devDependencies->>'jest' as 'jest', devDependencies->>'ts-jest' as 'ts-jest', devDependencies->>'jest-environment-jsdom' as 'jest-environment-jsdom', devDependencies['@testing-library/react'] as '@testing-library/react', devDependencies['@testing-library/jest-dom'] as '@testing-library/jest-dom', devDependencies->>'jest-junit' as 'jest-junit' FROM read_json_auto('package.json');"
[FII-CQI-100-CCP-04] Execute the below duckdb query in a CLI to verify package.json contains test:coverage
and test:ci
command.
duckdb -s "(SELECT name,type,version,scripts['test:coverage'],scripts['test:ci'] FROM read_json_auto('package.json'));"
[FII-CQI-100-CCP-05] Execute the below duckdb query in a CLI to run the test:coverage
command.
duckdb -s "SELECT UNNEST(regexp_split_to_array('$(npm run test:coverage -- --verbose=true 2>&1)', '\n')) as 'Test Result';"
ensure getting output as
Test Suites: (count) failed, (count) passed, (count) total
Tests: (count) failed, (count) passed, (count) total
Snapshots: (count) failed, (count) passed, (count) total
Time: (duration) s
Ran all test suites.
Table will contain the coverage result and a lcov result will be generated in '/coverage/lcov-report'
folder.
[FII-CQI-100-CCP-06] Execute the below duckdb query in a CLI to run the test:ci
command.
duckdb -s "SELECT UNNEST(regexp_split_to_array('$(npm run test:ci -- --verbose=true 2>&1)', '\n')) as 'Test Result';"
Ensure getting coverage report as mentioned above along with a junit.xml
file in the project folder.