New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jasmine-fail-fast

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jasmine-fail-fast - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

jasmine-fail-fast.sublime-project

69

dist/jasmine-fail-fast.js

@@ -6,2 +6,5 @@ 'use strict';

});
exports.init = init;
exports.getSpecReferences = getSpecReferences;
exports.disableSpecs = disableSpecs;

@@ -14,2 +17,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var refs = undefined;
// Jasmine doesn't yet have an option to fail fast. This "reporter" is a workaround for the time

@@ -20,3 +25,21 @@ // being, making Jasmine essentially skip all tests after the first failure.

exports['default'] = function () {
function init() {
refs = getSpecReferences();
return {
specDone: function specDone(result) {
if (result.status === 'failed') {
disableSpecs(refs);
}
}
};
}
/**
* Gather references to all jasmine specs and suites, through any (currently hacky) means possible.
*
* @return {Object} An object with `specs` and `suites` properties, arrays of respective types.
*/
function getSpecReferences() {
var specs = [];

@@ -43,22 +66,28 @@ var suites = [];

return {
specDone: function specDone(result) {
// Hacky workaround to facilitate "fail fast". Disable all specs (basically `xit`), then
// remove references to all before/after functions, else they'll still run. Disabling the
// suites themselves does not appear to have an effect.
if (result.status === 'failed') {
specs.forEach(function (spec) {
return spec.disable();
});
suites.forEach(function (suite) {
suite.beforeFns = [];
suite.afterFns = [];
suite.beforeAllFns = [];
suite.afterAllFns = [];
});
}
}
specs: specs,
suites: suites
};
};
}
module.exports = exports['default'];
/**
* Hacky workaround to facilitate "fail fast". Disable all specs (basically `xit`), then
* remove references to all before/after functions, else they'll still run. Disabling the
* suites themselves does not appear to have an effect.
*/
function disableSpecs() {
if (!refs) {
throw new Error('jasmine-fail-fast: Must call init() before calling disableSpecs()!');
}
refs.specs.forEach(function (spec) {
return spec.disable();
});
refs.suites.forEach(function (suite) {
suite.beforeFns = [];
suite.afterFns = [];
suite.beforeAllFns = [];
suite.afterAllFns = [];
});
}
{
"name": "jasmine-fail-fast",
"version": "1.1.0",
"version": "2.0.0",
"description": "Allow Jasmine tests to \"fail-fast\", exiting on the first failure instead of running all tests no matter what. ",

@@ -26,3 +26,3 @@ "repository": {

"devDependencies": {
"babel": "5.6.14",
"babel": "5.6.23",
"jasmine": "^2.3.1",

@@ -29,0 +29,0 @@ "mkdirp": "^0.5.1"

@@ -17,4 +17,28 @@ # jasmine-fail-fast [![build status](https://travis-ci.org/Updater/jasmine-fail-fast.svg?branch=master)](https://travis-ci.org/Updater/jasmine-fail-fast)

var failFast = require('jasmine-fail-fast');
jasmine.getEnv().addReporter(failFast.init());
```
jasmine.getEnv().addReporter(failFast());
### Examples
#### Protractor
In the Protractor conf file:
```javascript
onPrepare: function() {
...
var failFast = require('jasmine-fail-fast');
jasmine.getEnv().addReporter(failFast.init());
...
}
```
#### As a Jasmine helper
Create a new .js file within the [helpers](http://jasmine.github.io/2.3/node.html#section-9) [folder](http://jasmine.github.io/2.3/node.html#section-Load_configuration_from_a_file_or_from_an_object.):
```javascript
//<path-to-helpers>/fail-fast.js
var failFast = require('jasmine-fail-fast');
jasmine.getEnv().addReporter(failFast.init());
```
#### grunt-contrib-jasmine
Set up as a helper, [optionally overriding the default helpers path](https://github.com/gruntjs/grunt-contrib-jasmine#optionshelpers).
import suite from './suite';
import failFast from '../src/index';
import {init} from '../src/index';
jasmine.getEnv().addReporter(failFast());
jasmine.getEnv().addReporter(init());
suite();
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