0.0.1 • Published 4 years ago

mocha-requirements v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

Introduction

(WORK IN PROGRESS)

Custom mocha reporter that detects requirement IDs and otuputs a .csv report or updates the input one

Demo

Run

npm run demo

And open the resulting reqs_results.csv file

Usage

Example cypress configuration:

{
  // ...
  "reporter": "../../node_modules/mocha-requirements-reporter",
  "mochaRequirementsReporterOptions": {
    "requirementsFile": "./requirements.csv",
    "outputFile": "./requirements_results.csv",
    "requirementIdColumn": "REQ_ID",
    "requirementIDregex": "REQ\\d+",
    "verbose": "true",
    "failedLabel": "Failed",
    "passedLabel": "Passing",
    "partialLabel": "Some passed",
    "skippedLabel": "Pending",
    "notTestedLabel": "(!) Not tested"
  }
  // ...
}

Example:

Given the following input test:

describe('Functionality 1 (REQ001000) tests', () => {
  it('Should do A (REQ001001)', () => {
    expect(1).equal(1);
  });
  it('Should do B (REQ001002)', () => {
    expect(1).equal(2);
  });
  xit('Should do C (REQ001003) - not tested yet', () => {});
});

The regular expression /REQ\d+/ will be used to detect any requirement ids in the specs and output the test results to a requirements_results.csv file with the following format | REQ_ID | TestResult | | ------ | ---------- | | REQ001000 | Some passed | | REQ001001 | Passing | | REQ001002 | Failed | | REQ001003 | Pending |

Notice how the REQ001000 was marked as "Some passed": this is because two different tests under a scope that mentioned this requirement were evaluated, and some passed / some failed.

If an input requirements.csv file is passed, its contents will be transferred to the output file and updated with the test results, i.e. | REQ_ID | Comments | TestResult | | ------ | --- | ---------- | | REQ001000 | ... | Some passed | | REQ001001 | | Passing | | REQ001002 | | Failed | | REQ001003 | | Pending | | REQ002000 | ... | (!) Not tested | | REQ003000 | | (!) Not tested|

Note: use the overwrite option if you want test results to be written directly to the same input file

0.0.1

4 years ago