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

jasmine-disable-remaining

v0.3.0

Published

Disable all remaining specs on the first spec failure.

Downloads

17

Readme

jasmine-disable-remaining 0.3.0 (2016-05-13)

When a spec fails, either disable all remaining specs, or all remaining specs in the same file, or all specs in suites matching a pattern.

GitHub issues GitHub release GitHub tag npm

NPM

Provided as a reporter class for the jasmine test framework.

Installation

The easiest way is to keep jasmine-disable-remaining as a devDependency in your package.json. Just run

npm install jasmine-disable-remaining --save-dev

to let npm automatically add it there.

Configuration

protractor

In your protractor.conf.js file

  • At the top, or with the other require lines, add:
const JasmineDisableRemaining = require('jasmine-disable-remaining');
  • In the config.onPrepare function, add:
    browser.params.jasmineDisableRemainingReporter = new JasmineDisableRemaining(jasmine);

    if (browser.params.disableRemainingSpecsOnFail === true) {
        browser.params.jasmineDisableRemainingReporter.jasmineDisableRemaining.config.allSpecsByCLI.disableSpecs = true;
    }

    jasmine.getEnv().addReporter(browser.params.jasmineDisableRemainingReporter);

grunt + protractor

If you are using grunt, this configuration will allow you to specify the protractor flag from the grunt command line.

You must modify the protractor configuration in your Gruntfile.js as:

    protractor: {
        options: {
            args: {
                params: {
                    // Map the `grunt` command line argument:
                    //     --disableRemainingSpecsOnFail=true
                    // to the `protractor` boolean property:
                    //     browser.params.disableRemainingSpecsOnFail
                    disableRemainingSpecsOnFail: grunt.option('disableRemainingSpecsOnFail')
                }
            }
        }
    }

grunt + regular jasmine

TODO

Usage

Disabling is not turned on until/unless you specify so either on the command line or somewhere in your test code.

protractor

To just disable all tests after the first fail, run your usual protractor command with the extra flag:

--params.disableRemainingSpecsOnFail=true

e.g.:

protractor --params.disableRemainingSpecsOnFail=true

grunt

To just disable all tests after the first fail, run your usual grunt command with the extra flag:

--disableRemainingSpecsOnFail=true

e.g.:

grunt test --disableRemainingSpecsOnFail=true

Dynamic

You can also specify dynamically (within you tests) when to disable all remaining specs.

Disable all remaining specs

    const config = browser.params.jasmineDisableRemainingReporter.jasmineDisableRemaining.config;
    config.allSpecsDynamic.disableSpecs = true;

Use this if you want to disable all tests after the first fail. It must be set before the spec you're interested in.

Typically, you would put it in a beforeAll. You can also just set it in config.onPrepare.

Disable all remaining specs in a file

Turn on using (typically in a beforeAll)

    const config = browser.params.jasmineDisableRemainingReporter.jasmineDisableRemaining.config;
    config.allFileSpecsDynamic.disableSpecs = true;

Turn off using (typically in a afterAll)

    const config = browser.params.jasmineDisableRemainingReporter.jasmineDisableRemaining.config;
    config.allFileSpecsDynamic.disableSpecs = false;

Use this if you want to disable all tests in a file after the first fail. It must be set before the spec you're interested in. Please note this setting is global. It must be turned off so it doesn't affect other files.

TL; DR: if you don't remember to turn this off, all remaining files will have this turned on.

You can also just set it in config.onPrepare and then for any file with a failure, all remaining specs in that file will be disabled.

Disable all specs in suites matching a pattern

Use this if you want to disable all tests in any suites with matching description.

This is useful if you have a large number of specs that are broken in to "categories", and have them broken down across a large number of files from basic to complex. Take the following example scenario of types of suite files.

You have multiple "categories" of components being tested (e.g., "admin-panel", "client-panel"), broken down as follows in each category:

  • Smoke tests -- these tests run first, verifying all the lowest level required interactions (e.g., REST calls)
  • Existence tests -- these tests run second, ensuring all components exist, are present, are visible, etc.
  • Rudimentary tests -- these tests run third, and perform simple interactions
  • Comprehensive tests -- these tests run last, and are the full/complex tests

If any upper level specs fail, the subsequent level would also fail.

E.g., if your "admin-panel" smoke tests fail, you would want to disable only the remaining "admin-panel" tests. So, all your "admin-panel" spec files would have a top-most describe('admin-panel: blah blah'..., and your matcher pattern would be /^admin-panel:/.

Also, by breaking the tests up in this way, you may be able to more easily determine if the issues are fundamental or system wide.

Turn on using

    const jasmineDisableRemaining = browser.params.jasmineDisableRemainingReporter.jasmineDisableRemaining;
    let matcherGUID;

    beforeAll(() => {
        matcherGUID = jasmineDisableRemaining.addSuitesMatcher(/^Some prefix/, {
            message: [
                '---------------------------------------------------------------------------------------------------',
                '\nSpecs have FAILED and specified that all specs in suites matching /^Some prefix/ should be disabled',
                '\n---------------------------------------------------------------------------------------------------'
            ]
        });
    });

Turn off using

    afterAll(() => {
        browser.params.jasmineDisableRemainingReporter.jasmineDisableRemaining.removeSuitesMatcher(matcherGUID);
    });

NOTE: if you don't remember to turn this off, any remaining spec that fails will cause these matched suites to be disabled

Change the failure messages

There are three different types of messages:

    const config = browser.params.jasmineDisableRemainingReporter.jasmineDisableRemaining.config;
    config.allSpecsByCLI.message = 'disabling all specs turned on by command line';
    config.allSpecsDynamic.message = 'disabling all specs turned on in a suite';
    config.allFileSpecsDynamic.message = 'disabling all specs in a file turned on in a suite';

See defaultConfig in dist/jasmine-disable-remaining.js for all default message vaules.

To change e.g., allFileSpecsDynamic message using (typically in a beforeAll)

    config.allFileSpecsDynamic.message = 'my custom message string';

or

    config.allFileSpecsDynamic.message = [
        '-------------------------',
        '\nMy custom verbose message',
        '\n-------------------------'
    ];

Revert to the default message using (typically in a afterAll)

    config.allFileSpecsDynamic.message = null;

Advanced

By default, when using "Disable all remaining specs in a file", disabling of afterAllFns and afterFns is turned off, so that those functions are not disabled. This is because it is assumed that by default, there may be essential cleanup that may need to happen.

If you turn these on so that the become disabled, just remember that you won't be able to turn off any settings after a fail.

Changelog / Release History

See CHANGELOG.md.

Thanks

Thanks for the idea https://github.com/Updater/jasmine-fail-fast