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

@fav/test.framework

v0.2.3

Published

Javascript test framework like Mocha.

Downloads

7

Readme

@fav/test.framework NPM MIT Licese Build Status Coverage status

Javascript test framework like Mocha.

"fav" is an abbreviation of "favorite" and also the acronym of "for all versions". This package is intended to support all Node.js versions and many browsers as possible. At least, this package supports Node.js >= v0.10 and major Web browsers: Chrome, Firefox, IE11, Edge, Vivaldi and Safari.

Install

To install from npm:

$ npm install --save @fav/test.framework

NOTE: npm < 2.7.0 does not support scoped package, but old version Node.js supports it. So when you use such older npm, you should download this package from github.com, and move it in node_modules/@fav/test.framework/ directory manually.

Usage

For Node.js:

var Framework = require('@fav/test.framework');
var fw = new Framework(),
    describe = fw.suite,
    it = fw.test,
    before = fw.before,
    after = fw.after,
    beforeEach = fw.beforeEach,
    afterEach = fw.afterEach;

describe.skip = fw.skipSuite;
it.skip = fw.skipTest;
describe.only = fw.onlySuite;
it.only = fw.onlyTest;
<script src="fav.test.framework.min.js"></script>
<script>
var Framework = fav.test.framework;
var fw = new Framework(),
    describe = fw.suite,
    it = fw.test,
    before = fw.before,
    after = fw.after,
    beforeEach = fw.beforeEach,
    afterEach = fw.afterEach;

describe.skip = fw.skipSuite;
it.skip = fw.skipTest;
describe.only = fw.onlySuite;
it.only = fw.onlyTest;
</script>

API

class Framework

This class is a test framework like Mocha.

constructor(void)

Creates an instance of this class. This constructor receives no arguments.

.suite(title, cb) : void

Registers a test suite to a test tree.

| Parameter | Type | Description | |:----------|:--------:|:-------------------------| | title | string | The title of this suite. | | cb | function | The callback function to create a test tree |

.test(title, cb) : void

Registers a test case to a test tree.

If fn is not specified, this test is regarded as a skipped test.

| Parameter | Type | Description | |:----------|:--------:|:-------------------------| | title | string | The title of this test | | cb | function | The callback function which runs a test case |

.before([ title, ] cb) : void

Registers a 'before' hook which runs before all suites and tests in the same level of this hook.

| Parameter | Type | Description | |:----------|:--------:|:-------------------------| | title | string | The title of this hook (Optional) | | cb | function | The callback function of this hook |

.after([ title, ] cb) : void

Registers a 'after' hook which runs after all suites and tess in the same level of this hook.

| Parameter | Type | Description | |:----------|:--------:|:-------------------------| | title | string | The title of this hook (Optional) | | cb | function | The callback function of this hook |

.beforeEach([ title, ] cb) : void

Registers a 'beforeEach' hook which runs before each test in the same and lower levels of this hook.

| Parameter | Type | Description | |:----------|:--------:|:-------------------------| | title | string | The title of this hook (Optional) | | cb | function | The callback function of this hook |

.afterEach([ title, ] cb) : void

Registers a 'afterEach' hook which runs after each test in the same and lower levels of this hook.

| Parameter | Type | Description | |:----------|:--------:|:-------------------------| | title | string | The title of this hook (Optional) | | cb | function | The callback function of this hook |

.skipSuite(title, fn) : void

Registers a skipped suite which skips all child suites and tests of this suite to a test tree.

| Parameter | Type | Description | |:----------|:--------:|:-------------------------| | title | string | The title of this suite | | cb | function | The callback function to create a test tree |

.skipTest(title, fn) : void

Registers a skipped test which skips all child suites and tests of this suite to a test tree.

| Parameter | Type | Description | |:----------|:--------:|:-------------------------| | title | string | The title of this test | | cb | function | The callback function of a test case |

.onlySuite(title, fn) : void

Registers an exclusive test suite which runs child tests in this suite exclusively.

| Parameter | Type | Description | |:----------|:--------:|:-------------------------| | title | string | The title of this suite | | cb | function | The callback function to create a test tree |

.onlyTest(title, fn) : void

Registers an exclusive test case.

| Parameter | Type | Description | |:----------|:--------:|:-------------------------| | title | string | The title of this test | | cb | function | The callback function which runs a test case |

.run([cb]) : void

Runs tests in the test tree of this framework object.

| Parameter | Type | Description | |:----------|:--------:|:-------------------------| | cb | function | The callback function which run when all tests finished. (Optional) |

.on(eventName, handler) : void

Registers an event handler.

| Parameter | Type | Description | |:------------|:--------:|:-------------------------| | eventName | string | An event name | | handler | function | An event handler |

Events

'start' event

Is fired when a suite or a test is started. This event is fired even suite or test are skipped, but not when they are excluded by other .onlySuite or .onlyTest.

'succeed' event

Is fired when a test ends with no error.

'error' event

Is fired when a test ends with errors. This event is also fired when a test is timeout.

'timeout' event

Is fired when a test is timeout.

'skip' event

Is fired when a test is skipped.

'end' event

Is fired when a suite or a test ends. This event is fired even when a test is error or skipped, but not when they are excluded by other .onlySuite or .onlyTest.

Properties

_retries : number

Is retry times of failure tests.

_slow : number

Is threshold milliseconds specifying "slow" test cases.

_timeout : number

Is threshold milliseconds specifying "timeout" test cases.

Checked

Node.js (11〜)

| Platform | 11 | 12 | 13 | 14 | 15 | |:---------:|:------:|:------:|:------:|:------:|:------:| | macOS |◯|◯|◯|◯|◯| | Windows10 |◯|◯|◯|◯|◯| | Linux |◯|◯|◯|◯|◯|

Node.js (4〜10)

| Platform | 4 | 5 | 6 | 7 | 8 | 9 | 10 | |:---------:|:------:|:------:|:------:|:------:|:------:|:------:|:------:| | macOS |◯|◯|◯|◯|◯|◯|◯| | Windows10 |◯|◯|◯|◯|◯|◯|◯| | Linux |◯|◯|◯|◯|◯|◯|◯|

io.js (1〜3)

| Platform | 1 | 2 | 3 | |:---------:|:------:|:------:|:------:| | macOS |◯|◯|◯| | Windows10 |◯|◯|◯| | Linux |◯|◯|◯|

Node.js (〜0.12)

| Platform | 0.8 | 0.9 | 0.10 | 0.11 | 0.12 | |:---------:|:------:|:------:|:------:|:------:|:------:| | macOS |◯|◯|◯|◯|◯| | Windows10 |◯|◯|◯|◯|◯| | Linux |◯|◯|◯|◯|◯|

Web browsers

| Platform | Chrome | Firefox | Vivaldi | Safari | Edge | IE11 | |:---------:|:------:|:-------:|:-------:|:------:|:------:|:------:| | macOS |◯|◯ |◯ |◯| -- | -- | | Windows10 |◯|◯ |◯ | -- |◯|◯| | Linux |◯|◯ |◯ | -- | -- | -- |

License

Copyright (C) 2018-2020 Takayuki Sato

This program is free software under MIT License. See the file LICENSE is this distribution for more details.