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

esmock

Package Overview
Dependencies
Maintainers
1
Versions
107
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esmock

esmock

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
22K
increased by12.23%
Maintainers
1
Weekly downloads
 
Created
Source

esmock

(c)Bumblehead

npm version Build Status

This package must be used with node's experimental --loader,

ava --node-arguments="--loader=esmock"
mocha --loader=esmock

Add the command to your package.json,

{
  "name": "my-module",
  "type": "module",
  "scripts" : {
    "unit-test": "ava --node-arguments=\"--loader=esmock\""
  }
}

And use it

import test from 'ava';
import esmock from 'esmock';

test('should mock module and local file at the same time', async t => {
  const main = await esmock('./local/main.js', {
    'astringifierpackage' : o => JSON.stringify(o),
    './local/util.js' : {
      exportedFunction : () => 'foobar'
    }
  });

  t.is(main(), 'foobar, ' + JSON.stringify({ test: 'object' }));
});

changelog

  • 0.1.0 Apr.10.2021
    • adds support for native es modules

Keywords

FAQs

Package last updated on 10 Apr 2021

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