New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@salestrip/stub

Package Overview
Dependencies
Maintainers
7
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@salestrip/stub

A simple stub helper for Jest

  • 2.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-69.23%
Maintainers
7
Weekly downloads
 
Created
Source

@salestrip/stub

Build Status

A simple stub helper for Jest.

Install

npm i -D @salestrip/stub

Usage

const stub = require('@salestrip/stub')
const fooModule = require('modules/foo.module')

beforeEach(() => {
  stub(fooModule, 'method')
})

afterEach(() => {
  fooModule.method.restore()
})

it('resolves', () => {
  fooModule.method.resolves('value')
  return expect(fooModule.method()).resolves.toBe('value')
})

it('resolves once', async () => {
  fooModule.method.resolvesOnce('value')
  await expect(fooModule.method()).resolves.toBe('value')
  expect(fooModule.method()).toBeUndefined()
})

it('rejects', () => {
  fooModule.method.rejects('value')
  return expect(fooModule.method()).rejects.toBe('value')
})

it('rejects once', async () => {
  fooModule.method.rejectsOnce('value')
  await expect(fooModule.method()).rejects.toBe('value')
  expect(fooModule.method()).toBeUndefined()
})

it('returns', () => {
  fooModule.method.returns('value')
  expect(fooModule.method()).toBe('value')
})

it('returns once', () => {
  fooModule.method.returnsOnce('value')
  expect(fooModule.method()).toBe('value')
  expect(fooModule.method()).toBeUndefined()
})

it('throws', () => {
  fooModule.method.throws(new Error('value'))
  expect(fooModule.method()).toThrow('value')
})

it('throws once', () => {
  fooModule.method.throwsOnce(new Error('value'))
  expect(fooModule.method()).toThrow('value')
  expect(fooModule.method()).toBeUndefined()
})

Release

To release a new version, use npm. Using npm version will update the version in package.json before committing the resulting file change to git and adding the appropriate git tag. Pushing a tagged version to origin will trigger a CI deployment to the npm registry.

To release a bugfix update the patch version.

npm version patch
git push
git push --tags

To release a feature update the minor version.

npm version minor
git push
git push --tags

To release a breaking change update the major version.

npm version major
git push
git push --tags

Keywords

FAQs

Package last updated on 07 Aug 2019

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