# jasmine-promises

> Return Promises from your asynchronous Jasmine tests

Latest version **0.4.1** (published 2016-01-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install jasmine-promises
pnpm add jasmine-promises
yarn add jasmine-promises
bun add jasmine-promises
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.1 |
| Published | 2016-01-30 |
| First published | 2015-10-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 17 |
| Maintainers | matthew.jh |
| Keywords | jasmine, promise, async, testing, done |

## Links

- npm: https://www.npmjs.com/package/jasmine-promises
- Repository: https://github.com/matthewjh/jasmine-promises
- Homepage: https://github.com/matthewjh/jasmine-promises#readme
- Issues: https://github.com/matthewjh/jasmine-promises/issues
- npm.io page: https://npm.io/package/jasmine-promises

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 0.4.1 (latest) — 2016-01-30
- 0.4.0 — 2015-10-13
- 0.3.0 — 2015-10-13

## README

# jasmine-promises

[![Travis CI build status](https://api.travis-ci.org/matthewjh/jasmine-promise.png)](https://travis-ci.org/matthewjh/jasmine-promise)

Write asynchronous tests easier by returning `Promise`s from your spec functions.

No need to call `done` and `done.fail`.

````javascript
describe('my fancy thing', function () {
	beforeEach(function () {
		return doSomePreparatoryTaskThatIsAsync();
	});

    it('should be extra fancy', function () {
        return fancyAsync().then(function (thing) {
            expect(thing).toBeFancy();
        });
    });
});
````

Benefits:
* Works with any `then`able. ✓
* Simply return a promise from a test -- no need to call `done` and `done.fail` ✓
* Automatic error handling when using native `Promise`'s'. When writing such tests manually, you have to explictly catch the error with `.catch` and then pass the error to `done.fail` or rethrow. Unhandled `Promise` rejections are gobbled up so if you forget to do this you can miss out on debugging info. ✓
* Works with `it`, `fit`, `beforeEach`, `afterEach`, `beforeAll`, and `afterAll`. ✓


## Installation

Note: only compatible with Jasmine 2 at this point.

````
npm install jasmine-promises --save-dev
````

Then ensure that `jasmine-promises` is loaded before your tests are loaded. This can be done by either...

manually requiring the module at the top of your test file(s) e.g. if using browserify:

````javascript
require('jasmine-promises');

describe('my fancy thing', function () {
	it('should be extra fancy', function () {
		return fancyAsync().then(function (thing) {
			expect(thing).toBeFancy();
		});
	});
});

````

loading it via your test runner e.g. Karma:

````javascript
module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',


    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],


    // list of files / patterns to load in the browser
    files: [
      'node_modules/jasmine-promises/dist/jasmine-promises.js',
      'test/**/*.spec.js'
    ],
````

---
_Source: https://npm.io/package/jasmine-promises · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
