jasmine-spec-name-patch

1.1.0 • Public • Published

jasmine spec name patch

CircleCI npm version Greenkeeper badge

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

Readme

Keywords

Package Sidebar

Install

npm i jasmine-spec-name-patch

Weekly Downloads

1

Version

1.1.0

License

MIT

Last publish

Collaborators

  • quramy