sinonjs / sinonjs/sinon

Extract sandbox and fake into separate modules

Open
#2,145 12 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pinned
Dominant language
JavaScript
Stars
9.8k
Forks
808
PR merge metrics
No merged PRs in 30d

Description

I'd like to propose a way how we can make sinon more modular and allow to compose a version that only has the fake API and no spy, stub, mock and ideally also has optional lolex and nise.

Why?

The API surface of Sinon is too large and removing APIs is really difficult and a long process. Therefore, we might just keep it the way it is, have Sinon integrate all the features that we offer, but maybe allow to compose smaller installations as well.

How?

With #2144 I have separated the fake implementation from spy. This makes it possible to

  • move the common logic from util into @sinonjs/commons
  • extract the proxy.js, call.js, call-util.js, fake-api.js, ... into a separate module. Maybe @sinonjs/proxy?
  • extract a minimal, generic sandbox implementation that just offers hooks to install things on it, maybe called @sinonjs/sandbox. This would become the sinon default sandbox instance.
  • extract the fake.js implementation into @sinonjs/fake.

There are multiple options how fake, lolex and nise could be registered on the sandbox then.

What do you think?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the separation described in #2144 and the existing fake, proxy.js, call.js, call-util.js, fake-api.js, util, sandbox, lolex, and nise components. Clarify the desired module boundaries and registration approach before changing code; done would mean a decided, modular extraction plan that supports the proposed smaller installations.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.