Socket
Socket
Sign inDemoInstall

proxy-mocks

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    proxy-mocks

Provide mocks utilizing the Proxy API


Version published
Weekly downloads
590
increased by4.06%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

[0.3.0] - 2023-11-23

Changed

  • Allow assignments to readonly properties in Mocks

Readme

Source

proxy-mocks

Generate mocks for any class or object.

Example

// import { IMock, Mock } from 'proxy-mocks/jest';
import { IMock, Mock } from "proxy-mocks/sinon";
import Dependency from "./dependency";
import Implementation from "./implementation";

describe("Implementation", () => {
  let dependency: IMock<Dependency>;

  let implementation: Implementation;

  beforeEach(() => {
    dependency = Mock.of(Dependency);

    implementation = new Implementation(dependency);
  });

  test("your test", () => {
    dependency.someMethod.returns("your result");

    const result = implementation.anotherMethod();

    expect(result).toEqual("your result");
  });
});

FAQs

Last updated on 23 Nov 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc