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?
I am trying to stub the
EnvlopesApiprototype in my unit tests, but it doesn't seem possible to do this. However,ApiClientcan be stubbed successfully.The first stub does not generate an error; however, the second stub fails with a type error:
Why can I not stub the
EnvelopesApiprototype, but theApiClientprototype is stubbable?