Nice to have a --fail-fast option that process.exit(1) after first error found.
This might be something jasmine would need to implement, but what you can do is toss this in your describe:
afterEach(function() {
var passed = jasmine.getEnv().currentSpec.results().passed();
if(!passed) {
jasmine.getEnv().specFilter = function(spec) {
return false;
};
}
});
I'm sure you can do something fancy with a spechelper if you're so inclined.
Thanks you so much @stolidity that works!!
I would also like to console log the file name of the failed spec, i expanded jasmine.getEnv() and children but couldn't find the offending file path nor file name, just describe() and it() contents there among other stuff.
Any chance you know where to find it?
@elgalu I haven't tested this, but maybe you could modify the function and if it doesn't pass, prior to overwriting specFilter, output some message explaining that jasmine.getEnv().currentSpec.description was the test that failed. I could be wrong, as I haven't tried it, but I think that's what your looking for.
Can't edit on my phone, but uhhh, yeah. I misread what you were asking, apparently. 1am problems... Heh. I will try to figure out if there is a way to do that tomorrow, and if anyone else figures out if it is possible before me, that would be fantastic.
:) hehe don't worry i'm just reading this.
Precisely! i would like the file name of current spec, otherwise i'll have to hard code it into the first describe, probably :(
Yeah, I couldn't find any value where the filename is stored. The easiest solution is, at the top of each spec (inside the describe so it's fired when the spec is actually run as opposed to when the spec is loaded into the suite), you could set a globally defined variable like global.fileName, then when you have one fail, you could output global.fileName when it tries to bail.
Thanks @stolidity , unfortunately it didn't work until I put it inside the it() blocks, when i put it inside every describe() it actually gets the value of the last spec loaded, not the last spec run.
So will use this:
describe(module.filename, function() {
it('should work for now to know the offending spec file name', function() {
expect(false).toBeTruthy();
});
});
This is a test framework issue, so I opened an issue about it for minijasminenode: https://github.com/juliemr/minijasminenode/issues/20
Closing this one!
Hello,
I am at present on the version 0.4.0 (grunt-runner-protractor cant support 1.0.0 for now) and I needed the same feature
My fork : https://github.com/ludovicPelle/minijasminenode.git ( Only the file lib / reporter.js is impacted)
The fix from @stolidity is nice, but unfortunately Jasmine does not call afterEach after timeouts. As far as I can see there is no hook for it, unless you use reporters.
Hi!
I am using Protractor with Cucumber (and I also run my tests on Travis with Gulp). I have not found a way to fail when the first failed test occurs... Would you include that in Protractor? Is there a workaround I can use?
Thanks!
This works for me, when using protractor with cucumber, add the fail-fast option to cucumberOpts in the protractor conf file, the quotes around the 'fail-fast' are needed.
cucumberOpts: {
require: [
'../features/step_definitions/*.js',
],
format: 'pretty', // or summary, progress
'fail-fast': true
},
Most helpful comment
This works for me, when using protractor with cucumber, add the fail-fast option to cucumberOpts in the protractor conf file, the quotes around the 'fail-fast' are needed.
cucumberOpts: {
require: [
'../features/step_definitions/*.js',
],
format: 'pretty', // or summary, progress
'fail-fast': true
},