jasmine-stop-on-blocker v1.1.0
jasmine-stop-on-blocker
This project was originally designed for a personal use. Today it is open to everyone.
So if you think you have any improvements or features to add, I would be more than happy to add you as a collaborator.
Installation
npm i jasmine-stop-on-blocker
Description
jasmine-stop-on-blocker
is a small and simple custom reporter for jasmine framework.
Designed for handling jasmine runs to stop 'suites' if an important spec has failed.
A lot of times we find our self running a suites that has an important spec that all is
sibling specs depend on him (a blocker spec by definition). and if this blocker spec
will fail we don't have any reason to go on.
Or If we noticed that there are too many failures in one test, which means that it may
be a connection problem (for example) and not necessarily a problem in our app.
Clarification note:
Injasmine
's configuration there is the ability offailFast
(stopSpecOnFailure
in older versions)
That what it does is to stop the suites if one spec has been fail.
But there is a limitation with this. Because sometimes we do want the suites to continue even when one (or more) specs has been fail. But if the spec that fail is a 'blocker' one, (meaning, other specs depend on him) I don't see any reason to go on (most of times any way). So,on this note, this is the reason forjasmine-stop-on-blocker
.
Usage
In your jasmine helper file
Create one if you don't have one yet (Make sure jasmine.json file pointed to it).
javaScript
const jasmineStopOnBlocker = require('Jasmine-stop-on-blocker').default;
jasmine.getEnv().addReporter(new Jasmine_StopOnBlockerSpecFailure({
// If set to true, a failure blocker spec will not stop your test.
disable: false,
stopOnBlockerFailure: true,
desiredAttemptBeforeFailure: 5,
writeReporterInfoToJson: {
writeInfo: true,
resultDir: 'out/jasmine-blockerResults',
deleteHistory: false
}
}))
typeScript
import jasmineStopOnBlocker from 'Jasmine-stop-on-blocker';
jasmine.getEnv().addReporter(new jasmineStopOnBlocker({
// If set to true, a failure blocker spec will not stop your test.
disable: false,
stopOnBlockerFailure: true,
desiredAttemptBeforeFailure: 5,
writeReporterInfoToJson: {
writeInfo: true,
resultDir: 'out/jasmine-blockerResults',
deleteHistory: false
}
}));
Example
In Your spec
describe('Jasmine - stop on blocker specs', () => {
// If `jasmine-stop-on-blocker` defined to stop when blocker spec fails
it('This is a blocker spec. and mark as @blocker', () => {
expect(false).toBeTrue();
});
// If `jasmine-stop-on-blocker` defined to stop when number of fails in suites
// his reach to `desiredAttemptBeforeFailure` configuration
it('Even without a blocker spec ', () => {
expect(true).toBeFalse();
});
// Pending
it('All other specs are on pending status', () => {});
// ...
});
Configuration
disable
(boolean) whether to disablejasmine-stop-on-blocker
reporter. If set to true,jasmine-stop-on-blocker
will not affect your run at all.stopOnBlockerFailure
(boolean) Whether to stop on suites when a spec mark as a '@blocker' as faileddesiredAttemptBeforeFailure
(number) Config how many times jasmine will keep running in case of a fail before stops. If the number of steps failed is greater than the desired number, thenjasmine-stop-on-blocker
will stop suite's run.desiredAttemptBeforeFailure
can be also defind per test by entering@desiredAttempt:${number}
to the test description. if no desired attempt has been provided in test description, the amount will be has mention in the configwriteReporterInfoToJson
Config whether to write the result into a folder on your working directory or not. - except to keys- writeToJson (boolean) - whether to write to json file
- ResultDir (string) - Where to keep the result files. if resultDir not exist,
jasmine-stop-on-blocker
will create one for you - deleteHistory (boolean) whether to delete old files
licence
This project is licensed under the terms of the MIT licence