jasmine-spec-name-patch
v1.1.0
Published
Allow to use spec name in Jasmine afterEach callback
Downloads
70
Readme
jasmine spec name patch
Allows to get spec's name in Jasmine beforeEach
and afterEach
callback. See also jasmine/jasmine#611).
How to use
npm i jasmine-spec-name-patch
require('jasmine-spec-name-patch');
describe('My awesome function', function() {
beforeEach(function() {
console.log(this.fullName); // -> My awesome function should returns ...
});
// or
beforeEach((done, { fullName }) => {
console.log(fullName); // -> My awesome function should returns ...
done();
});
it('should returns...', function() { /* test code */ });
afterEach(function() {
console.log(this.fullName); // -> My awesome function should returns ...
});
// or
afterEach((done, { fullName }) => {
console.log(fullName); // -> My awesome function should returns ...
done();
});
});
Decorate beforeEach / afterEach fn
You can also intercept afterEach
function.
const wrap = require('jasmine-spec-name-patch/before-each');
// Or you can use jasmine-spec-name-patch/after-each also.
wrap(function(context, complete, delegate) {
// something you want,,,
if (delegate.length === 0) {
delegate.apply(context);
complete();
} else {
delegate.apply(context, [complete]);
}
});
License
MIT