Skip to content

Mocks native JS date objects to be agnostic of the current engines timezone

Notifications You must be signed in to change notification settings

tobilen/jest-date-serializer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Example configuration:

{
"name": "my-awesome-project",
"devDependencies": {
  "jest": "^23.6.0",
  "jest-date-serializer": "^0.0.1"
},
"jest": {
    "snapshotSerializers": [
      "jest-date-serializer"
    ]
  },
}
  1. All your dates will be stripped of timezone offsets 👯‍♀️

About

Mocks native JS date objects to be agnostic of the current engines timezone

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published