Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jasmine-promise-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jasmine-promise-wrapper

Promise handling for jasmine

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6K
increased by44.2%
Maintainers
1
Weekly downloads
 
Created
Source

jasmine-promise-wrapper

Build Status

Purpose of this library

This library shall simplify promise handling within jasmine. To achieve this, it provides some wrapper functions which can handle returned promises. The specs will wait for the resolution or rejection of those promises.

API

The following wrapping functions are exported by this library:

  • it(description, fn, timeout)
  • beforeEach(fn, timeout)
  • afterEach(fn, timeout)
  • beforeAll(fn, timeout)
  • afterAll(fn, timeout)

Additionaly there is an invert(promise) function that takes promise and returns an inverted promise that is rejected with the original resolution or resolved with the original rejection. This comes in handy when expecting promises to be rejected.

Simple example

import {it} from "jasmine-promise-wrapper";

const unit = () =>
  new Promise(resolve =>
    setTimeout(() => resolve("success"), 1000));

it("should wait for a promise", () => {
  return unit()
    .then(result => {
      expect(result).toBe("success");
    });
});

// alternative with implicit returns:

it("should wait for a promise", () =>
  unit()
    .then(result =>
      expect(result).toBe("success")));

// alternative with async/await:

it("should wait for a promise", async () => {
  const result = await unit();
  expect(result).toBe("success");
});

Keywords

FAQs

Package last updated on 30 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc