Skip to content

Improve mocking dates/times in e2e tests #2942

@rejas

Description

@rejas

Some module e2e tests need to fake a certain date/time to be run, especially the calendar module.

There isnt (yet) a general way to mock the current date/time in the e2e tests. Only hackish solutions exist, like for the compliments module for displaying a compliment on a specific date:

https://github.com/MichMich/MagicMirror/blob/a328ce537faf8d9b90d7eb2c09237fe83ae3a827/tests/e2e/modules/compliments_spec.js#L83

Here a mockDate is in the test config which gets read in the mm-js-logic. Using test logic in normal code is of course a no-no!

There are quite a few solutions out there, like sinon, mockDate or adding a jest.mock. Alas, the author hasnt gotten any of them to run for faking a test :-(

Adding the functionality to mock a certain date/time would open up a lot of new test posibilities, for example this new feature could be tested very easily.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions