Skip to content

Cannot stub non-existent property #376

Description

@rob-clother-saible

I am trying to stub the EnvlopesApi prototype in my unit tests, but it doesn't seem possible to do this. However, ApiClient can be stubbed successfully.

  it('should not create an envelope when the user is changed from invited to invited', async () => {
    sinon.stub(ApiClient.prototype, 'requestJWTUserToken').resolves({
      body: { access_token: 'access-token' }
    });
    const createEnvelopeStub = sinon.stub(EnvelopesApi.prototype, 'createEnvelope').resolves({
      envelopeId: 'envelopeId'
    })
    const before = await createNewPendingUser(false);
    const after = await PendingUser.fromId(before.id);
    await callOnUpdate(triggers.onInvitationAccepted, before, after);
    assert(createEnvelopeStub.notCalled);
  });

The first stub does not generate an error; however, the second stub fails with a type error:

Cannot stub non-existent property createEnvelope

Why can I not stub the EnvelopesApi prototype, but the ApiClient prototype is stubbable?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions