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

jest-create-mock-instance

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-create-mock-instance - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

0

index.d.ts

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ var jestMock = require("jest-mock");

8

package.json
{
"name": "jest-create-mock-instance",
"version": "1.0.0",
"version": "1.0.1",
"description": "Create class mock instances easily with Jest",

@@ -19,8 +19,8 @@ "main": "index.js",

"license": "MIT",
"dependencies": {
"jest-mock": ">=21.0.0"
"peerDependencies": {
"jest-mock": "*"
},
"devDependencies": {
"jest": "^21.1.0"
"jest": "^21.2.1"
}
}

@@ -5,3 +5,3 @@ ## Description

I've been always fan of using ```sinon.createStubInstance()``` in my tests. Unfortunately, Jest doesn't expose similar API to create new mocked instance for given class constructor. Using ```jest.fn()``` is not very convienment for various cases, take an example of these classes and unit test:
I've been always fan of using ```sinon.createStubInstance()``` in my tests. Unfortunately, Jest doesn't expose similar API to create new mocked instance for given class constructor. Using ```jest.fn()``` or jest's module mocks is not very convienment for various cases, take an example of these classes and unit test:

@@ -49,3 +49,3 @@

By using ```jest.fn()``` you must mock your module before and instantiate ```Food``` directly:
By using jest module mocks you must mock your module before and instantiate ```Food``` directly:

@@ -90,3 +90,3 @@ ```js

beforeEach(() => {
food = createMockInstance(food);
food = createMockInstance(Food);
});

@@ -93,0 +93,0 @@ ```

Sorry, the diff of this file is not supported yet

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