vendredi 22 février 2019

How to match some values of object using sinon stub

I've been writing test using sinon. During the same I wrote stub where some input parameters are passed and an object is returned. This object returns some values and a random date value generated by system at the time of execution. So need guidance on following.

  1. How can I handle the same as the matching arguments are static in nature and I don't know the possible value of the date generated by actual code.
  2. How can we skip certain key values of an object using sinon. i.e. say object has following values. const object = {name: "abc", employeeNumber : "123"} I only want to check if name is "abc" and don't need to match employeeNumber.

Aucun commentaire:

Enregistrer un commentaire