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

stu

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stu

Stub dependencies when testing

3.2.0
latest
Source
npm
Version published
Weekly downloads
362
12.77%
Maintainers
1
Weekly downloads
 
Created
Source

Stu

A shoddy replacement for jest that works with mocha and sinon but is way faster.

Basically it allows you to stub entire modules that are required by the file you are testing.

Installation

npm install --save-dev stu

Usage

import test from 'ava';
import * as stu from 'stu';

test.beforeEach((t) => {
  t.context = {
    ...t.context,
    library: stu.mock('library'),
    mycode: stu.test('../mycode').default
  };
})

test('should do stuff with thing', (t) => {
    const { library, mycode } = t.context;

  library.returns('some value');
  mycode();
  t.deepEqual(library.args, [['a', 'b', 'c']]);
});

Keywords

mock

FAQs

Package last updated on 30 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