https://github.com/tobilen/jest-date-serializer
Mocks native JS date objects to be agnostic of the current engines timezone
https://github.com/tobilen/jest-date-serializer
hacktoberfest serializer timezone
Last synced: 6 days ago
JSON representation
Mocks native JS date objects to be agnostic of the current engines timezone
- Host: GitHub
- URL: https://github.com/tobilen/jest-date-serializer
- Owner: tobilen
- Created: 2018-10-02T17:45:52.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T01:58:25.000Z (over 3 years ago)
- Last Synced: 2025-11-30T17:51:40.784Z (7 months ago)
- Topics: hacktoberfest, serializer, timezone
- Language: JavaScript
- Homepage:
- Size: 554 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# jest-date-serializer
A custom serializer for jest that strips timezone offsets away from dates before serializing them. This will prevent failing snapshot tests when running them on machines with different timezone.
## Installation
1. Run `yarn add --dev jest-date-serializer` to add the serializer to your project
2. Add the serializer to your [jest configuration](https://jestjs.io/docs/en/configuration.html#snapshotserializers-array-string).
Example configuration:
```json
{
"name": "my-awesome-project",
"devDependencies": {
"jest": "^23.6.0",
"jest-date-serializer": "^0.0.1"
},
"jest": {
"snapshotSerializers": [
"jest-date-serializer"
]
},
}
```
3. All your dates will be stripped of timezone offsets 👯♀️