Socket
Socket
Sign inDemoInstall

ember-mockdate

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-mockdate

MockDate within your Ember application


Version published
Weekly downloads
2.5K
decreased by-77.46%
Maintainers
1
Weekly downloads
 
Created
Source

ember-mockdate

Use MockDate within your Ember applications.

ember-mockdate is an updated version of the great ember-mockdate-shim using the same api.

Compatibility

  • Ember.js v3.16 or above
  • Ember CLI v3.16 or above
  • Node.js v10 or above

Installation

ember install ember-mockdate

Usage

MockDate's set and reset methods are renamed to freezeDateAt and unfreezeDate respectively.

import { freezeDateAt, unfreezeDate } from 'ember-mockdate';

freezeDateAt(new Date('1/12/2017'));
unfreezeDate();

This is primarily useful for keeping the time data consistent between tests (ie: for visual diffs a la Percy). Any library methods that rely on new Date() will return consistent outputs. For example: moment() and faker.date.recent

You can use this in the beforeEach and afterEach hooks of your tests, or anywhere else you want to freeze the date at, how ever many times you want!

Please note that acceptance test support is only available in Ember >2.15.1 as that is when backburner.js introduced the ability to make "now" configurable. More info here.

Contributing

See the Contributing guide for details.

This repo is a fork of ember-mockdate-shim. Thank you to all the contributors.

License

This project is licensed under the MIT License.

Keywords

FAQs

Package last updated on 07 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc