Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/quramy/jasmine-spec-name-patch
Allow to get spec's name in Jasmine before/after callback functions
https://github.com/quramy/jasmine-spec-name-patch
jasmine test
Last synced: 17 days ago
JSON representation
Allow to get spec's name in Jasmine before/after callback functions
- Host: GitHub
- URL: https://github.com/quramy/jasmine-spec-name-patch
- Owner: Quramy
- License: mit
- Created: 2017-08-18T14:10:30.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-09-21T00:23:12.000Z (over 5 years ago)
- Last Synced: 2024-11-19T10:57:04.584Z (about 1 month ago)
- Topics: jasmine, test
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jasmine spec name patch
[![CircleCI](https://circleci.com/gh/Quramy/jasmine-spec-name-patch.svg?style=svg)](https://circleci.com/gh/Quramy/jasmine-spec-name-patch)
[![npm version](https://badge.fury.io/js/jasmine-spec-name-patch.svg)](https://badge.fury.io/js/jasmine-spec-name-patch)
[![Greenkeeper badge](https://badges.greenkeeper.io/Quramy/jasmine-spec-name-patch.svg)](https://greenkeeper.io/)Allows to get spec's name in Jasmine `beforeEach` and `afterEach` callback. See also [jasmine/jasmine#611](https://github.com/jasmine/jasmine/issues/611)).
## How to use
```sh
npm i jasmine-spec-name-patch
``````js
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.```js
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