@cuties/wall

1.1.2 • Public • Published

wall

Wall is a tool that includes static analysis and test coverage. It was mainly made for Page and based on the Async Tree Pattern.

NPM Version Build Status codecov

Install

npm install @cuties/wall

Init eslint

node_modules/.bin/eslint --init

Test

npm test

Build

npm run build

Async objects

ExecutedLint

This async object represents the process where static analysis is executed.

new ExecutedLint(process, './src').call()

Async call: executedLint.

ExecutedTestCoverage

This async object represents the process where test coverage is executed.

new ExecutedTestCoverage(
  process, './test-executor.js'
).call()

File test-executor contains script that runs all your tests. You can use this library for doing such things.

Async call: executedTestCoverage.

ExecutedTestCoverageCheck

This async object represents the process where test coverage check is executed(after running tests via ExecutedTestCoverage). If coverage falls below a threshold (that can be configured via ConfiguredTestCoverage) the process fails. You can configure required test coverage percentages of lines, functions and branches via options in params.

new ExecutedTestCoverageCheck(
  new ExecutedTestCoverage(process, '/test-executor.js'),
  { lines: 100, functions: 100, branches: 100, 'statements': 100 }
).call()

Async call: executedTestCoverageCheck.

ExecutedTestCoverageReport

This async object represents the process where test coverage is reported (after running tests via ExecutedTestCoverage).

new ExecutedTestCoverageReport(
  new ExecutedTestCoverage(process, '/test-executor.js'), 'json-summary'
).call()

Async call: executedTestCoverageReport. About format(default value is text) of report you can read here.

Complete example

For making your project more qualitative use following composition:

const {
  ExecutedLint,
  ExecutedTestCoverage,
  ExecutedTestCoverageCheck,
  ExecutedTestCoverageReport
} = require('@cuties/wall')

new ExecutedLint(process, './src').after(
  new ExecutedTestCoverageCheck(
    new ExecutedTestCoverageReport(
      new ExecutedTestCoverage(
        process, './test-executor.js'
      ), 'json-summary'
    ), { lines: 100, functions: 100, branches: 100, statements: 100 }
  )
).call()

test-executor.js

const executor = require('test-executor');

executor('./test');

test-executor library

Log total coverage (LoggedTotalCoverageByJsonSummary)

If you use json-summary in ExecutedTestCoverageReport, then this async object generates report into coverage/coverage-summary.json file. And you can log to console total coverage numbers via LoggedTotalCoverageByJsonSummary, ReadDataByPath(cutie-fs) and ParsedJson(cutie-json):

const { ReadDataByPath } = require('@cuties/fs')
const { ParsedJSON } = require('@cuties/json')
const { ExecutedTestCoverage, ExecutedTestCoverageReport, LoggedTotalCoverageByJsonSummary } = require('./../index')

new ExecutedTestCoverageReport(
  new ExecutedTestCoverage(process, './test-executor.js'),
  'json-summary'
).after(
  new LoggedTotalCoverageByJsonSummary(
    new ParsedJSON(
      new ReadDataByPath('coverage/coverage-summary.json', { encoding: 'utf8' })
    ), (linesPct, statementsPct, functionsPct, branchesPct) => {
      return (linesPct + statementsPct + functionsPct + branchesPct) / 4
    }
  )
).call()

First argument of LoggedTotalCoverageByJsonSummary is json that contains coverage numbers(lines, statements, functions, branches percentages), second one is a function that calculates total number (in that case we just take average value of coverage numbers).

Output would look like:

Total coverage: 100%

Package Sidebar

Install

npm i @cuties/wall

Weekly Downloads

5

Version

1.1.2

License

MIT

Unpacked Size

21.2 kB

Total Files

33

Last publish

Collaborators

  • guseyn