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

mocha-bundle-ui

v3.0.0

Published

Mocha BDD ui extended with bundle

Downloads

27

Readme

Adds the bundle keyword to an existing UI. bundle allows you to bundle tests across files into a single suite with a before and after scripts that are executed for every bundle.

This UI was originally made to use with E2E testing frameworks that use Mocha. In this context the UI allows you to separate speed optimizations from your file structure. This allows you to have both flexibility and a short runtime.

bundle('foo', function() {
    it('is now a part of the bundle named `foo`', function() {
        // ...
    });
});

bundle('foo', function() {
    it('is part of the same bundle named `foo` that now contains two tests', function() {
        // ...
    });
});

Contents


Design choices

Bundles work across files

This is the main purpose of the UI. This allows you to separate technical arrangement from your administrative logic.

You can bundle on objects

To enable bundling each bundle needs an id. This can be either a string or an object. When using an object the bundle id can double as input for the bundle.beforeEach and bundle.afterEach functions. This allows you to customise the before and after scripts to suit each bundle.

Bundles only work within their nesting level

Bundling on different nesting levels can be confusing which can lead to accidental bundling. To keep things clean and clear bundling across nesting levels is not possible.

A notable exception to this rule is calling bundle within a test block. This can be unpredictable but when it works it will always bundle on the top nesting level.

Bundles don't support .skip and .only

Bundles don't support this, but their contents do. Enabling this would get very confusing very fast as it would potentially have effect on multiple files.


Limits

As with everything there are limits, below are the ones identified right now that aren't because of a design choice. Found a limit? Please let me know by creating an issue.

  • There are no default bundle values
  • bundle can only be used in combination with Supported UIs

Installation

npm install mocha-bundle-ui

Then require & specify the UI by calling mocha with the --require & --ui flags:

mocha --require mocha-bundle-ui --ui BDD-bundle

Or add the flags to mocha.opts:

--require mocha-bundle-ui
--ui BDD-bundle

Supported UIs

Mocha bundle UI is an extention of existing UIs. The following are supported at this point.

Note on adding a UI: Extending an existing UI is actually pretty easy in most cases, but it sadly requires the UI to be copied into the Mocha bundle UI repo. If you want to use bundle in an unsupported UI please add an issue or make a pull request.

Details about adding bundle to your own UI

Mocha BDD

--ui BDD-bundle
bundle.beforeEach(function() {
    // ...
});

bundle.afterEach(function() {
    // ...
});

bundle('foo', function() {
    describe('Bundling in BDD', function() {
        it('is now a part of the bundle named foo', function() {
            // ...
        });
    });
});

More details about BDD-bundle ›

Mocha TDD

--ui TDD-bundle
bundle.setup(function() {
    // ...
});

bundle.teardown(function() {
    // ...
});

bundle('foo', function() {
    suite('Bundling in BDD', function() {
        test('The suite is now a part of the bundle named foo', function() {
            // ...
        });
    });
});

More details about TDD-bundle ›