Test Code: index.js
Mockdate is an npm module that allows you to mock the current date.
Note: This example uses mockdate@^2.0.5
because [email protected]
does not work in the browser. Read the full explanation in this thread.
Use the clientScripts
function to inject the mockdate
module and add the code that uses this module to set the browser date.
The client code returns the date and the test code verifies that the date is equal to the date in the clientScript
function.