Step Four: Validating Your Tests

The following resources can be used as a guide for project setup and code coverage tips.

Code Coverage

Jest's code coverage feature allows you to track the number of tested lines in your script. Enabling this feature allows you to review a detailed report of your script's coverage and understanding ways to improve it. A good measure of code coverage is at least 80% of your entire script. Although 100% completion is obtainable, it may not always be realistic for every script. For more information about code coverage, see Jest Code Coverage. When you have enabled code coverage feature, the coverage report will generate when you run npm test in your terminal.

To enable code coverage, you must configure the package file (package.json) in your SuiteCloud project:

            {
  "name": "suitecloud-project",
  "version": "1.0.0",
  "scripts": {
    "test": "jest --testPathPattern=__tests__ --coverage --collectCoverageFrom=src/FileCabinet/SuiteScripts/*"
  },
  "devDependencies": {
    "@oracle/suitecloud-unit-testing": "^1.2.0",
    "jest": "^27.4.7"
  },
  "dependencies": {
    "suitecloud-unit-testing-stubs": "^1.0.2"
  }
} 

          

General Notices