GithubHelp home page GithubHelp logo

wagenet / ember-mockdate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kiwiupover/ember-mockdate

0.0 0.0 0.0 567 KB

Mock date

License: MIT License

JavaScript 82.05% HTML 16.63% Handlebars 1.32%

ember-mockdate's Introduction

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.

ember-mockdate's People

Contributors

ember-tomster avatar kiwiupover avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.