npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

feature-cup

v0.0.5

Published

Share how your node.js test automation system covers the features of your application.

Downloads

9

Readme

feature-cup Tests Coverage Status npm version License: MIT

Create feature coverage reports for your test automation system. We are aware that reporting is a key component for test automation suites, however one important question that is usually not answered is "how much of your system is covered by these tests?" or "what features are not covered and we should verify manually?".

feature-cup allows us to specify the functional structure of the system-under-test and then match the test automation code to the functional structure. The result is a feature coverage report that shows how much of our system is covered by those tests.

Note that feature-cup does not require tests to run, as it does a static analysis of the test code.

Installation

npm install feature-cup --save-dev

Usage

Find the help by running:

feature-cup --help

Here is a basic usage of the reporter:

feature-cup --features ./demo/features.json --tests "./demo/specs/**/*.spec.js" --output console

features.json

The features.json file is a json file that contains the system functional structure. It is used to create the feature coverage report. The file is a json array of module objects, such as:

{
  "system": {
    "name": "My System",
    "modules": [
      {
        "name": "Module A",
        "features": [
          {
            "name": "Feature 1",
            "description": "This is feature 1 of module A"
          }
        ]
      }
    ]
  }
}

Tests

The tests are the files that contain the test automation code. They may be written for mocha, jasmine or jest test runners. This reporter will parse all the "describe" blocks in the test files and match them to the features in the features.json file. The reporter will then output the feature coverage report.

The tests are specified using the --tests option. The tests are specified using the glob pattern. For example, to specify all the files in the "specs" folder, use:

--tests "./specs/**/*.spec.js"

In the demo folder, we have the following test files:

./demo
├──demo.js // usage through a NodeJS file
├──features.json // the functional structure of the system
├──reports
│  ├──feature-coverage-report.html // sample html report
└──specs // the test files
   ├──module_a.spec.js
   ├──module_b // feature-cup will find all test files recursively
   │  ├──module_b.spec.js
   │  ├──module_b_feature_4.spec.js
   │  └──module_b_feature_6.spec.js
   ├──module_c.spec.js
   └──module_f
      └──module_f.spec.js // all "describe" blocks in files will be matched to the features in the features.json file

Output

The output is specified using the --output option. The output can be "console" or "html".

If the output is "html", then the --report option may be specified. The report option is the path where report will be generated. If not specified, report will be saved in "reports" folder. For example:

--output console
--output html --report feature-coverage

Examples

Find the source of examples in the repo: https://github.com/oscarcenteno/feature-cup-example

# Sample output report to console
feature-cup --features ./demo/features.json --tests "./demo/specs/**/*.spec.js" --output console

Alt text

# Sample output report to html file
feature-cup --features ./demo/features.json --tests "./demo/specs/**/*.spec.js" --output html --report feature-coverage

will output as an html report at demo/reports/feature-coverage.html:

Alt text)

Development

Install dependencies

npm install

Run tests

Business and presentation logic are covered by unit tests.

npm test

Static code checking

npm run typecheck # check typescript types
npm run lint # check code style

Get code coverage report

npm run coverage

Coverage information is reported to coveralls.io and can be found at https://coveralls.io/github/oscarcenteno/feature-cup.

# Command used by github actions to report coverage on each commit to main branch, see .github/workflows/nodejs.yml
npm run ci:coverage

End to End testing

Here, make sure everything works together.

npm run demo:console # check no errors are shown in the console
npm run demo:html #check the report in the "reports" folder

Contributors

  • [Oscar Centeno] (https://github.com/oscarcenteno)

License

MIT

References