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

expect-even-more-jest

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expect-even-more-jest - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

5

dist/index.d.ts

@@ -0,1 +1,3 @@

/// <reference types="jest" />
import Mock = jest.Mock;
import "expect-more-jest";

@@ -13,2 +15,5 @@ export declare function sleep(ms: number): Promise<void>;

export declare function areEqual(left: any, right: any, debug?: boolean): boolean;
export declare function isJasmineSpy(a: any): boolean;
export declare function isJestMock(a: any): boolean;
export declare function fetchArgs(subject: Mock | jasmine.Spy): any[];
declare global {

@@ -15,0 +20,0 @@ namespace jest {

55

dist/index.js

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.stringLike = exports.prettyPrint = exports.notFor = exports.runAssertionsAsync = exports.runAssertions = exports.assert = exports.areEqual = exports.sleep = void 0;
exports.stringLike = exports.prettyPrint = exports.notFor = exports.runAssertionsAsync = exports.runAssertions = exports.assert = exports.fetchArgs = exports.isJestMock = exports.isJasmineSpy = exports.areEqual = exports.sleep = void 0;
const fs_1 = __importDefault(require("fs"));

@@ -33,2 +33,30 @@ require("expect-more-jest");

exports.areEqual = areEqual;
function isJasmineSpy(a) {
return a &&
a.calls &&
typeof a.calls.all === "function";
}
exports.isJasmineSpy = isJasmineSpy;
function isJestMock(a) {
return a &&
a.mock &&
Array.isArray(a.mock.calls);
}
exports.isJestMock = isJestMock;
function fetchArgs(subject) {
// jasmine spies come from doing `spyOn(thing, "method")`
// jest mocks come from `jest.fn()`
if (isJasmineSpy(subject)) {
const spy = subject;
return spy.calls.all().map(c => c.args);
}
else if (isJestMock(subject)) {
const mock = subject;
return mock.mock.calls;
}
else {
throw new Error(`${subject} doesn't appear to be a jasmine spy or a jest mock?`);
}
}
exports.fetchArgs = fetchArgs;
function assert(expr, failMessage) {

@@ -267,16 +295,3 @@ if (!expr) {

expect(actual).toHaveBeenCalledWith(...args);
let allArgs;
// jasmine spies come from doing `spyOn(thing, "method")`
// jest mocks come from `jest.fn()`
if (isJasmineSpy(actual)) {
const spy = actual;
allArgs = spy.calls.all().map(c => c.args);
}
else if (isJestMock(actual)) {
const mock = actual;
allArgs = mock.mock.calls;
}
else {
throw new Error("actual doesn't appear to be a spy or a mock?");
}
const allArgs = fetchArgs(actual);
const matching = allArgs.filter(a => {

@@ -294,12 +309,2 @@ try {

});
function isJasmineSpy(a) {
return a &&
a.calls &&
typeof a.calls.all === "function";
}
function isJestMock(a) {
return a &&
a.mock &&
Array.isArray(a.mock.calls);
}
},

@@ -306,0 +311,0 @@ async toBeCompleted(actual) {

{
"name": "expect-even-more-jest",
"version": "1.1.0",
"version": "1.2.0",
"description": "expect-more-jest with even more stuff",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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