Skip to content

Default server type when using sandbox.useFakeServer() doesn't match documentation #1534

@lsglick

Description

@lsglick
  • Sinon version : master
  • Environment :
  • Example URL :
  • Other libraries you are using:

What did you expect to happen?
Creating a fake server with sandbox.useFakeServer() should create a fakeServer instance. (According to docs here: http://sinonjs.org/releases/v3.2.0/sandbox/)

What actually happens
It creates a fakeServerWithClock instance.

How to reproduce

var sandbox = sinon.sandbox.create();
sandbox.useFakeServer();
// Verify sandbox.server is a fakeServerWithClock

Workaround is to manually set sandbox.serverPrototype before calling .useFakeServer() since unlike creating server from the sandbox config, there is no way to specify the server prototype when calling the method version of useFakeServer.

This appears to simply be due to setting the wrong prototype here:

serverPrototype: fakeServerWithClock,

So the default || fakeServer is never reached:

var proto = this.serverPrototype || fakeServer;
.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions