Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

section-tests

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

section-tests

TDD for node.js

  • 1.2.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.3K
decreased by-32.14%
Maintainers
1
Weekly downloads
 
Created
Source

Section Tests - TDD for node

A beautiful, extensible and lightweight async test framework.

Usage

1. Install the module

 npm i --save-dev section-tests

2. Add test command to your package.json file

"scripts": {
    "test": "./node_modules/.bin/section ./test/**/*.js"
},

You may use glob patterns for defining the files that should be loaded for executing the tests.

3. Create your test files

The section test framework generates structured messages from your test which then are processed by an output reporter. That reporter needs to be instantiated before the first test is executed.

Example:

import section, {SpecReporter} from 'section-tests';


// this must only be done in the first file
// that is executed for testing
section.use(new SpecReporter());


// lets do some preparations before we execute
// the actual tests
section.setup(async () => {

    await doSetupThings();

    // print status
    section.info('Things are set up!');
});


// now lets execute some tests
section('Outer Group', (section) => {
    section('Inner Group', (section) => {

        section.test('Test a', async() => {
            const result = await doSomething();
            asser(result);
        });

        section.test('Test a', async() => {
            const result = await doAnotherThing();
            asser(result);

            // print a neat log message
            section.success(`Got result ${result}`);
        });
    });
});

The resulting output looks like this:

Keywords

FAQs

Package last updated on 09 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc