<commit_before>{:title "Fake timers"
 :introduction "Fake timers is a synchronous implementation of `setTimeout` and friends that
Sinon.JS can overwrite the global functions with to allow you to more easily
test code using them. Fake timers provide a `clock` object to pass time, which
can also be used to control `Date` objects created through either `new Date();`
or `Date.now();` (if supported by the browser).

When faking timers with IE you also need
[sinon-ie-${current-version}](/releases/sinon-ie-${current-version}.js), which
should be loaded after sinon-${current-version}.js.

The fake timers can be used completely stand-alone by downloading
[sinon-timers-${current-version}](/releases/sinon-timers-${current-version}.js)
When using the fake timers in IE you also need
[sinon-timers-ie-${current-version}](/releases/sinon-timers-ie-${current-version}.js).
Load it after the first file.

<pre class=\"code-snippet timers\" data-lang=\"javascript\"><code>{
    setUp: function () {
        this.clock = sinon.useFakeTimers();
    },

    tearDown: function () {
        this.clock.restore();
    },

    \"test should animate element over 500ms\" : function(){
        var el = jQuery(\"&lt;div>&lt;/div>\");
        el.appendTo(document.body);

        el.animate({ height: \"200px\", width: \"200px\" });
        this.clock.tick(510);

        assertEquals(\"200px\", el.css(\"height\"));
        assertEquals(\"200px\", el.css(\"width\"));
    }
}</code></pre>"
 :apis<commit_msg>Now recommending `lolex` instead of sinon-timers for stand-alone usage. refs cjohansen/Sinon.JS#811<commit_after>{:title "Fake timers"
 :introduction "Fake timers is a synchronous implementation of `setTimeout` and friends that
Sinon.JS can overwrite the global functions with to allow you to more easily
test code using them. Fake timers provide a `clock` object to pass time, which
can also be used to control `Date` objects created through either `new Date();`
or `Date.now();` (if supported by the browser).

When faking timers with IE you also need
[sinon-ie-${current-version}](/releases/sinon-ie-${current-version}.js), which
should be loaded after sinon-${current-version}.js.

For standalone usage of fake timers it is recommended to use
[lolex](https://github.com/sinonjs/lolex) package instead. It provides the same
set features and was previously extracted from Sinon.JS.

<pre class=\"code-snippet timers\" data-lang=\"javascript\"><code>{
    setUp: function () {
        this.clock = sinon.useFakeTimers();
    },

    tearDown: function () {
        this.clock.restore();
    },

    \"test should animate element over 500ms\" : function(){
        var el = jQuery(\"&lt;div>&lt;/div>\");
        el.appendTo(document.body);

        el.animate({ height: \"200px\", width: \"200px\" });
        this.clock.tick(510);

        assertEquals(\"200px\", el.css(\"height\"));
        assertEquals(\"200px\", el.css(\"width\"));
    }
}</code></pre>"
 :apis
{'fraction_non_alphanumeric': 0.14932432432432433, 'fraction_numerical': 0.013175675675675676, 'mean_word_length': 3.6049766718506997, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7357639', 'n_tokens_mistral': 932, 'n_tokens_neox': 876, 'n_words': 285}