All the Software developers of Netspective Communications LLC across all the projects
must have a consistent code unit testing process.
Controls
All are required to adhere to the unit testing tool that aligns with their development technology listed below.
| Language / Framework | Unit Testing 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 unit testing tools. [FII-CQI-090-CUP-01]
-
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[FII-CQI-090-CUP-02]
-
Ensure to add the below provided content to package.json to run unit testing in the project using the
npm run testcommand"scripts": { "test": "jest", },[FII-CQI-090-CUP-03]
-
Ensure
npm run testcommand will run for unit testing whole project. [FII-CQI-006-CUP-04] -
Ensure to add and modify the configuration file
jest.config.cjs.module.exports = { preset: "ts-jest", testEnvironment: "jsdom", modulePathIgnorePatterns: ["playwright"], };[FII-CQI-006-CUP-05]
-
All React developers must ensure they are following React reference Project for React code quality.
Evidence
ReactJS
[FII-CQI-006-CUP-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' FROM read_json_auto('package.json');"
[FII-CQI-006-CUP-04] Execute the below duckdb query in a CLI to verify package.json contains test command.
duckdb -s "(SELECT name,type,version,scripts->>'test' FROM read_json_auto('package.json'));"
[FII-CQI-006-CUP-05] Execute the below duckdb query in a CLI to run the test command.
duckdb -s "SELECT UNNEST(regexp_split_to_array('$(npm run test -- --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.
As duckdb result, a tabular result will be generated.