{
  "doc": {
    "id": "api/commands/clock",
    "title": "clock | Cypress Documentation",
    "description": "Override native global functions related to time allowing them to be controlled synchronously via `cy.tick()` or the yielded `clock` object.",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/clock.md",
    "version": "3cf5b86b3403f604bdf7f3e35025c3bc3865e02c",
    "updated_at": "2026-05-07T17:44:31.931Z",
    "headings": [
      {
        "id": "api/commands/clock#clock",
        "text": "clock",
        "level": 1
      },
      {
        "id": "api/commands/clock#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/commands/clock#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/commands/clock#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/commands/clock#yields-learn-about-subject-management",
        "text": "Yields Learn about subject management",
        "level": 3
      },
      {
        "id": "api/commands/clock#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/commands/clock#no-args",
        "text": "No Args",
        "level": 3
      },
      {
        "id": "api/commands/clock#create-a-clock-and-use-it-to-trigger-a-setinterval",
        "text": "Create a clock and use it to trigger a setInterval",
        "level": 4
      },
      {
        "id": "api/commands/clock#access-the-clock-object-to-synchronously-move-time",
        "text": "Access the clock object to synchronously move time",
        "level": 4
      },
      {
        "id": "api/commands/clock#access-the-clock-object-to-restore-native-functions",
        "text": "Access the clock object to restore native functions",
        "level": 4
      },
      {
        "id": "api/commands/clock#now",
        "text": "Now",
        "level": 3
      },
      {
        "id": "api/commands/clock#specify-a-now-timestamp",
        "text": "Specify a now timestamp",
        "level": 4
      },
      {
        "id": "api/commands/clock#function-names",
        "text": "Function names",
        "level": 3
      },
      {
        "id": "api/commands/clock#specify-which-functions-to-override",
        "text": "Specify which functions to override",
        "level": 4
      },
      {
        "id": "api/commands/clock#using-cy-clock-with-cy-tick",
        "text": "Using cy.clock() with cy.tick()",
        "level": 4
      },
      {
        "id": "api/commands/clock#restore-clock",
        "text": "Restore clock",
        "level": 3
      },
      {
        "id": "api/commands/clock#change-current-system-time",
        "text": "Change current system time",
        "level": 3
      },
      {
        "id": "api/commands/clock#notes",
        "text": "Notes",
        "level": 2
      },
      {
        "id": "api/commands/clock#iframes",
        "text": "iframes",
        "level": 3
      },
      {
        "id": "api/commands/clock#iframes-not-supported",
        "text": "iframes not supported",
        "level": 4
      },
      {
        "id": "api/commands/clock#behavior",
        "text": "Behavior",
        "level": 3
      },
      {
        "id": "api/commands/clock#clock-behavior-before-cy-mount",
        "text": "clock behavior before cy.mount()",
        "level": 4
      },
      {
        "id": "api/commands/clock#clock-behavior-before-cy-visit",
        "text": "clock behavior before cy.visit()",
        "level": 4
      },
      {
        "id": "api/commands/clock#rules",
        "text": "Rules",
        "level": 2
      },
      {
        "id": "api/commands/clock#requirements-learn-about-chaining-commands",
        "text": "Requirements Learn about chaining commands",
        "level": 3
      },
      {
        "id": "api/commands/clock#assertions-learn-about-assertions",
        "text": "Assertions Learn about assertions",
        "level": 3
      },
      {
        "id": "api/commands/clock#timeouts-learn-about-timeouts",
        "text": "Timeouts Learn about timeouts",
        "level": 3
      },
      {
        "id": "api/commands/clock#command-log",
        "text": "Command Log",
        "level": 2
      },
      {
        "id": "api/commands/clock#history",
        "text": "History",
        "level": 2
      },
      {
        "id": "api/commands/clock#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "chunks": [
    {
      "id": "api/commands/clock#syntax",
      "doc_id": "api/commands/clock",
      "heading": "Syntax",
      "heading_level": 2,
      "content_markdown": "## Syntax\n\n```\ncy.clock()cy.clock(now)cy.clock(now, functionNames)cy.clock(options)cy.clock(now, options)cy.clock(now, functionNames, options)\n```\n\n### Usage\n\n**Correct Usage**\n\n```\ncy.clock()\n```\n\n### Arguments\n\n**now _(number)_**\n\nA timestamp specifying where the clock should start.\n\n**functionNames _(Array)_**\n\nName of native functions that clock should override.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `cy.clock()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |\n\n### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)\n\n`cy.clock()` yields a `clock` object with the following methods:\n\n*   **`clock.tick(milliseconds)`**\n    \n    Move the clock the specified number of `milliseconds`. Any timers within the affected range of time will be called.\n    \n*   **`clock.restore()`**\n    \n    Restore all overridden native functions. This is automatically called between tests, so should not generally be needed.\n    \n*   **`clock.setSystemTime(now)`**\n    \n    Change the system time to the new `now`. Now can be a timestamp, date object, or not passed in which defaults to 0. No timers will be called, nor will the time left before they trigger change.\n    \n\nYou can also access the `clock` object via `this.clock` in a [`.then()`](/llm/markdown/api/commands/then.md) callback.\n",
      "section": "api",
      "anchors": [
        "syntax"
      ],
      "path": "/llm/json/chunked/api/commands/clock.json",
      "token_estimate": 248
    },
    {
      "id": "api/commands/clock#arguments",
      "doc_id": "api/commands/clock",
      "heading": "Arguments",
      "heading_level": 3,
      "content_markdown": "### Arguments\n\n**now _(number)_**\n\nA timestamp specifying where the clock should start.\n\n**functionNames _(Array)_**\n\nName of native functions that clock should override.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `cy.clock()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |\n",
      "section": "api",
      "anchors": [
        "arguments"
      ],
      "path": "/llm/json/chunked/api/commands/clock.json",
      "token_estimate": 84
    },
    {
      "id": "api/commands/clock#yields-learn-about-subject-management",
      "doc_id": "api/commands/clock",
      "heading": "Yields Learn about subject management",
      "heading_level": 3,
      "content_markdown": "### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)\n\n`cy.clock()` yields a `clock` object with the following methods:\n\n*   **`clock.tick(milliseconds)`**\n    \n    Move the clock the specified number of `milliseconds`. Any timers within the affected range of time will be called.\n    \n*   **`clock.restore()`**\n    \n    Restore all overridden native functions. This is automatically called between tests, so should not generally be needed.\n    \n*   **`clock.setSystemTime(now)`**\n    \n    Change the system time to the new `now`. Now can be a timestamp, date object, or not passed in which defaults to 0. No timers will be called, nor will the time left before they trigger change.\n    \n\nYou can also access the `clock` object via `this.clock` in a [`.then()`](/llm/markdown/api/commands/then.md) callback.\n",
      "section": "api",
      "anchors": [
        "yields-learn-about-subject-management"
      ],
      "path": "/llm/json/chunked/api/commands/clock.json",
      "token_estimate": 143
    },
    {
      "id": "api/commands/clock#examples",
      "doc_id": "api/commands/clock",
      "heading": "Examples",
      "heading_level": 2,
      "content_markdown": "## Examples\n\n### No Args\n\n#### Create a clock and use it to trigger a `setInterval`\n\n```\n// your app codelet seconds = 0setInterval(() => {  $('#seconds-elapsed').text(++seconds + ' seconds')}, 1000)\n```\n\n```\ncy.clock()cy.visit('/index.html')cy.tick(1000)cy.get('#seconds-elapsed').should('have.text', '1 seconds')cy.tick(1000)cy.get('#seconds-elapsed').should('have.text', '2 seconds')\n```\n\n#### Access the clock object to synchronously move time\n\nIn most cases, it's easier to use [`cy.tick()`](/llm/markdown/api/commands/tick.md) to move time, but you can also use the `clock` object yielded by `cy.clock()`.\n\n```\ncy.clock().then((clock) => {  clock.tick(1000)})\n```\n\nYou can call `cy.clock()` again for this purpose later in a chain if necessary.\n\n```\ncy.clock()cy.get('input').type('Jane Lane')cy.clock().then((clock) => {  clock.tick(1000)})\n```\n\nThe clock object is also available via `this.clock` in any [`.then()`](/llm/markdown/api/commands/then.md) callback.\n\n```\ncy.clock()cy.get('form').then(($form) => {  this.clock.tick(1000)  // do something with $form ...})\n```\n\n#### Access the clock object to restore native functions\n\nIn general, it should not be necessary to manually restore the native functions that `cy.clock()` overrides since this is done automatically between tests. But if you need to, the `clock` object yield has a `.restore()` method.\n\n```\ncy.clock().then((clock) => {  clock.restore()})\n```\n\nOr via `this.clock`:\n\n```\ncy.clock()cy.get('.timer').then(($timer) => {  this.clock.restore()  // do something with $timer ...})\n```\n\n### Now\n\n#### Specify a now timestamp\n\n*   End-to-End Test\n*   Component Test\n\n```\nconst now = new Date(2021, 3, 14) // month is 0-indexedcy.clock(now)cy.visit('/index.html')cy.get('#date').should('have.value', '04/14/2021')\n```\n\n```\nconst now = new Date(2021, 3, 14) // month is 0-indexedcy.clock(now)cy.mount(<DatePicker id=\"date\" />)cy.get('#date').should('have.value', '04/14/2021')\n```\n\n### Function names\n\n#### Specify which functions to override\n\nThis example below will only override `setTimeout` and `clearTimeout` and leave the other time-related functions as they are.\n\n```\ncy.clock(null, ['setTimeout', 'clearTimeout'])\n```\n\nNote that you must specify `Date` in order to override the current datetime. The example below affects the current datetime without affecting scheduled timers.\n\n```\ncy.clock(Date.UTC(2018, 10, 30), ['Date'])\n```\n\n#### `Using cy.clock()` with `cy.tick()`\n\n[Check out our example recipe testing spying, stubbing and time.](/llm/markdown/app/references/recipes.md#Stubbing-and-spying)\n\n### Restore clock\n\nYou can restore the clock and allow your application to resume normally without manipulating native global functions related to time. This is automatically called between tests.\n\n```\ncy.clock()cy.visit('http://localhost:3333')cy.get('#search').type('Acme Company')cy.tick(1000)// more test code here// restore the clockcy.clock().then((clock) => {  clock.restore()})// more test code here\n```\n\nYou could also restore by using [.invoke()](/llm/markdown/api/commands/invoke.md) to invoke the `restore` function.\n\n```\ncy.clock().invoke('restore')\n```\n\n### Change current system time\n\nHere we test that a timer still looks good if it has run for an hour, without triggering an hours worth of setInterval or requestAnimationFrame timers and overloading our CPU.\n\n```\ncy.clock(0)cy.visit('http://localhost:3333')cy.clock().then((clock) => {  clock.setSystemTime(60 * 60 * 1000 - 60);  // setSystemTime doesn't trigger any timers, so we run the last frame  // with tick to trigger a callback to update the timer.  clock.tick(60);})cy.get('#timer').should(...) // assert that it fits within the screen etc.// more test code here\n```\n\nYou could also change the system time by using [.invoke()](/llm/markdown/api/commands/invoke.md) to invoke the `setSystemTime` function.\n\n```\ncy.clock().invoke('setSystemTime', 60 * 60 * 1000)\n```\n",
      "section": "api",
      "anchors": [
        "examples"
      ],
      "path": "/llm/json/chunked/api/commands/clock.json",
      "token_estimate": 635
    },
    {
      "id": "api/commands/clock#no-args",
      "doc_id": "api/commands/clock",
      "heading": "No Args",
      "heading_level": 3,
      "content_markdown": "### No Args\n\n#### Create a clock and use it to trigger a `setInterval`\n\n```\n// your app codelet seconds = 0setInterval(() => {  $('#seconds-elapsed').text(++seconds + ' seconds')}, 1000)\n```\n\n```\ncy.clock()cy.visit('/index.html')cy.tick(1000)cy.get('#seconds-elapsed').should('have.text', '1 seconds')cy.tick(1000)cy.get('#seconds-elapsed').should('have.text', '2 seconds')\n```\n\n#### Access the clock object to synchronously move time\n\nIn most cases, it's easier to use [`cy.tick()`](/llm/markdown/api/commands/tick.md) to move time, but you can also use the `clock` object yielded by `cy.clock()`.\n\n```\ncy.clock().then((clock) => {  clock.tick(1000)})\n```\n\nYou can call `cy.clock()` again for this purpose later in a chain if necessary.\n\n```\ncy.clock()cy.get('input').type('Jane Lane')cy.clock().then((clock) => {  clock.tick(1000)})\n```\n\nThe clock object is also available via `this.clock` in any [`.then()`](/llm/markdown/api/commands/then.md) callback.\n\n```\ncy.clock()cy.get('form').then(($form) => {  this.clock.tick(1000)  // do something with $form ...})\n```\n\n#### Access the clock object to restore native functions\n\nIn general, it should not be necessary to manually restore the native functions that `cy.clock()` overrides since this is done automatically between tests. But if you need to, the `clock` object yield has a `.restore()` method.\n\n```\ncy.clock().then((clock) => {  clock.restore()})\n```\n\nOr via `this.clock`:\n\n```\ncy.clock()cy.get('.timer').then(($timer) => {  this.clock.restore()  // do something with $timer ...})\n```\n",
      "section": "api",
      "anchors": [
        "no-args"
      ],
      "path": "/llm/json/chunked/api/commands/clock.json",
      "token_estimate": 247
    },
    {
      "id": "api/commands/clock#create-a-clock-and-use-it-to-trigger-a-setinterval",
      "doc_id": "api/commands/clock",
      "heading": "Create a clock and use it to trigger a setInterval",
      "heading_level": 4,
      "content_markdown": "#### Create a clock and use it to trigger a `setInterval`\n\n```\n// your app codelet seconds = 0setInterval(() => {  $('#seconds-elapsed').text(++seconds + ' seconds')}, 1000)\n```\n\n```\ncy.clock()cy.visit('/index.html')cy.tick(1000)cy.get('#seconds-elapsed').should('have.text', '1 seconds')cy.tick(1000)cy.get('#seconds-elapsed').should('have.text', '2 seconds')\n```\n",
      "section": "api",
      "anchors": [
        "create-a-clock-and-use-it-to-trigger-a-setinterval"
      ],
      "path": "/llm/json/chunked/api/commands/clock.json",
      "token_estimate": 45
    },
    {
      "id": "api/commands/clock#access-the-clock-object-to-synchronously-move-time",
      "doc_id": "api/commands/clock",
      "heading": "Access the clock object to synchronously move time",
      "heading_level": 4,
      "content_markdown": "#### Access the clock object to synchronously move time\n\nIn most cases, it's easier to use [`cy.tick()`](/llm/markdown/api/commands/tick.md) to move time, but you can also use the `clock` object yielded by `cy.clock()`.\n\n```\ncy.clock().then((clock) => {  clock.tick(1000)})\n```\n\nYou can call `cy.clock()` again for this purpose later in a chain if necessary.\n\n```\ncy.clock()cy.get('input').type('Jane Lane')cy.clock().then((clock) => {  clock.tick(1000)})\n```\n\nThe clock object is also available via `this.clock` in any [`.then()`](/llm/markdown/api/commands/then.md) callback.\n\n```\ncy.clock()cy.get('form').then(($form) => {  this.clock.tick(1000)  // do something with $form ...})\n```\n",
      "section": "api",
      "anchors": [
        "access-the-clock-object-to-synchronously-move-time"
      ],
      "path": "/llm/json/chunked/api/commands/clock.json",
      "token_estimate": 109
    },
    {
      "id": "api/commands/clock#access-the-clock-object-to-restore-native-functions",
      "doc_id": "api/commands/clock",
      "heading": "Access the clock object to restore native functions",
      "heading_level": 4,
      "content_markdown": "#### Access the clock object to restore native functions\n\nIn general, it should not be necessary to manually restore the native functions that `cy.clock()` overrides since this is done automatically between tests. But if you need to, the `clock` object yield has a `.restore()` method.\n\n```\ncy.clock().then((clock) => {  clock.restore()})\n```\n\nOr via `this.clock`:\n\n```\ncy.clock()cy.get('.timer').then(($timer) => {  this.clock.restore()  // do something with $timer ...})\n```\n",
      "section": "api",
      "anchors": [
        "access-the-clock-object-to-restore-native-functions"
      ],
      "path": "/llm/json/chunked/api/commands/clock.json",
      "token_estimate": 88
    },
    {
      "id": "api/commands/clock#now",
      "doc_id": "api/commands/clock",
      "heading": "Now",
      "heading_level": 3,
      "content_markdown": "### Now\n\n#### Specify a now timestamp\n\n*   End-to-End Test\n*   Component Test\n\n```\nconst now = new Date(2021, 3, 14) // month is 0-indexedcy.clock(now)cy.visit('/index.html')cy.get('#date').should('have.value', '04/14/2021')\n```\n\n```\nconst now = new Date(2021, 3, 14) // month is 0-indexedcy.clock(now)cy.mount(<DatePicker id=\"date\" />)cy.get('#date').should('have.value', '04/14/2021')\n```\n",
      "section": "api",
      "anchors": [
        "now"
      ],
      "path": "/llm/json/chunked/api/commands/clock.json",
      "token_estimate": 57
    },
    {
      "id": "api/commands/clock#specify-a-now-timestamp",
      "doc_id": "api/commands/clock",
      "heading": "Specify a now timestamp",
      "heading_level": 4,
      "content_markdown": "#### Specify a now timestamp\n\n*   End-to-End Test\n*   Component Test\n\n```\nconst now = new Date(2021, 3, 14) // month is 0-indexedcy.clock(now)cy.visit('/index.html')cy.get('#date').should('have.value', '04/14/2021')\n```\n\n```\nconst now = new Date(2021, 3, 14) // month is 0-indexedcy.clock(now)cy.mount(<DatePicker id=\"date\" />)cy.get('#date').should('have.value', '04/14/2021')\n```\n",
      "section": "api",
      "anchors": [
        "specify-a-now-timestamp"
      ],
      "path": "/llm/json/chunked/api/commands/clock.json",
      "token_estimate": 55
    },
    {
      "id": "api/commands/clock#function-names",
      "doc_id": "api/commands/clock",
      "heading": "Function names",
      "heading_level": 3,
      "content_markdown": "### Function names\n\n#### Specify which functions to override\n\nThis example below will only override `setTimeout` and `clearTimeout` and leave the other time-related functions as they are.\n\n```\ncy.clock(null, ['setTimeout', 'clearTimeout'])\n```\n\nNote that you must specify `Date` in order to override the current datetime. The example below affects the current datetime without affecting scheduled timers.\n\n```\ncy.clock(Date.UTC(2018, 10, 30), ['Date'])\n```\n\n#### `Using cy.clock()` with `cy.tick()`\n\n[Check out our example recipe testing spying, stubbing and time.](/llm/markdown/app/references/recipes.md#Stubbing-and-spying)\n",
      "section": "api",
      "anchors": [
        "function-names"
      ],
      "path": "/llm/json/chunked/api/commands/clock.json",
      "token_estimate": 103
    },
    {
      "id": "api/commands/clock#specify-which-functions-to-override",
      "doc_id": "api/commands/clock",
      "heading": "Specify which functions to override",
      "heading_level": 4,
      "content_markdown": "#### Specify which functions to override\n\nThis example below will only override `setTimeout` and `clearTimeout` and leave the other time-related functions as they are.\n\n```\ncy.clock(null, ['setTimeout', 'clearTimeout'])\n```\n\nNote that you must specify `Date` in order to override the current datetime. The example below affects the current datetime without affecting scheduled timers.\n\n```\ncy.clock(Date.UTC(2018, 10, 30), ['Date'])\n```\n",
      "section": "api",
      "anchors": [
        "specify-which-functions-to-override"
      ],
      "path": "/llm/json/chunked/api/commands/clock.json",
      "token_estimate": 79
    },
    {
      "id": "api/commands/clock#restore-clock",
      "doc_id": "api/commands/clock",
      "heading": "Restore clock",
      "heading_level": 3,
      "content_markdown": "### Restore clock\n\nYou can restore the clock and allow your application to resume normally without manipulating native global functions related to time. This is automatically called between tests.\n\n```\ncy.clock()cy.visit('http://localhost:3333')cy.get('#search').type('Acme Company')cy.tick(1000)// more test code here// restore the clockcy.clock().then((clock) => {  clock.restore()})// more test code here\n```\n\nYou could also restore by using [.invoke()](/llm/markdown/api/commands/invoke.md) to invoke the `restore` function.\n\n```\ncy.clock().invoke('restore')\n```\n",
      "section": "api",
      "anchors": [
        "restore-clock"
      ],
      "path": "/llm/json/chunked/api/commands/clock.json",
      "token_estimate": 83
    },
    {
      "id": "api/commands/clock#change-current-system-time",
      "doc_id": "api/commands/clock",
      "heading": "Change current system time",
      "heading_level": 3,
      "content_markdown": "### Change current system time\n\nHere we test that a timer still looks good if it has run for an hour, without triggering an hours worth of setInterval or requestAnimationFrame timers and overloading our CPU.\n\n```\ncy.clock(0)cy.visit('http://localhost:3333')cy.clock().then((clock) => {  clock.setSystemTime(60 * 60 * 1000 - 60);  // setSystemTime doesn't trigger any timers, so we run the last frame  // with tick to trigger a callback to update the timer.  clock.tick(60);})cy.get('#timer').should(...) // assert that it fits within the screen etc.// more test code here\n```\n\nYou could also change the system time by using [.invoke()](/llm/markdown/api/commands/invoke.md) to invoke the `setSystemTime` function.\n\n```\ncy.clock().invoke('setSystemTime', 60 * 60 * 1000)\n```\n",
      "section": "api",
      "anchors": [
        "change-current-system-time"
      ],
      "path": "/llm/json/chunked/api/commands/clock.json",
      "token_estimate": 143
    },
    {
      "id": "api/commands/clock#notes",
      "doc_id": "api/commands/clock",
      "heading": "Notes",
      "heading_level": 2,
      "content_markdown": "## Notes\n\n### iframes\n\n#### iframes not supported\n\nNote that `cy.clock()` only applies to the `top` window on a web page. It will not override the time functions of any `iframe` embedded on the page.\n\n### Behavior\n\n#### clock behavior before `cy.mount()`\n\nUsing the [`cy.mount()`](/llm/markdown/api/commands/mount.md) command in a Cypress Component Test will render your component but does not affect the behavior of the page or window object. This means you can `mount` directly after calling `cy.clock()` to test the component against any changes you've made to the yielded clock object.\n\n#### clock behavior before `cy.visit()`\n\nIf you call `cy.clock()` before visiting a page with [`cy.visit()`](/llm/markdown/api/commands/visit.md), the page's native global functions will be overridden on window load, before any of your app code runs. So even if `setTimeout`, for example, is called on page load, it can still be controlled via [`cy.tick()`](/llm/markdown/api/commands/tick.md). This also applies if, during the course of a test, the page under test is reloaded or changed.\n",
      "section": "api",
      "anchors": [
        "notes"
      ],
      "path": "/llm/json/chunked/api/commands/clock.json",
      "token_estimate": 212
    },
    {
      "id": "api/commands/clock#iframes",
      "doc_id": "api/commands/clock",
      "heading": "iframes",
      "heading_level": 3,
      "content_markdown": "### iframes\n\n#### iframes not supported\n\nNote that `cy.clock()` only applies to the `top` window on a web page. It will not override the time functions of any `iframe` embedded on the page.\n",
      "section": "api",
      "anchors": [
        "iframes"
      ],
      "path": "/llm/json/chunked/api/commands/clock.json",
      "token_estimate": 44
    },
    {
      "id": "api/commands/clock#iframes-not-supported",
      "doc_id": "api/commands/clock",
      "heading": "iframes not supported",
      "heading_level": 4,
      "content_markdown": "#### iframes not supported\n\nNote that `cy.clock()` only applies to the `top` window on a web page. It will not override the time functions of any `iframe` embedded on the page.\n",
      "section": "api",
      "anchors": [
        "iframes-not-supported"
      ],
      "path": "/llm/json/chunked/api/commands/clock.json",
      "token_estimate": 41
    },
    {
      "id": "api/commands/clock#behavior",
      "doc_id": "api/commands/clock",
      "heading": "Behavior",
      "heading_level": 3,
      "content_markdown": "### Behavior\n\n#### clock behavior before `cy.mount()`\n\nUsing the [`cy.mount()`](/llm/markdown/api/commands/mount.md) command in a Cypress Component Test will render your component but does not affect the behavior of the page or window object. This means you can `mount` directly after calling `cy.clock()` to test the component against any changes you've made to the yielded clock object.\n\n#### clock behavior before `cy.visit()`\n\nIf you call `cy.clock()` before visiting a page with [`cy.visit()`](/llm/markdown/api/commands/visit.md), the page's native global functions will be overridden on window load, before any of your app code runs. So even if `setTimeout`, for example, is called on page load, it can still be controlled via [`cy.tick()`](/llm/markdown/api/commands/tick.md). This also applies if, during the course of a test, the page under test is reloaded or changed.\n",
      "section": "api",
      "anchors": [
        "behavior"
      ],
      "path": "/llm/json/chunked/api/commands/clock.json",
      "token_estimate": 165
    },
    {
      "id": "api/commands/clock#clock-behavior-before-cy-mount",
      "doc_id": "api/commands/clock",
      "heading": "clock behavior before cy.mount()",
      "heading_level": 4,
      "content_markdown": "#### clock behavior before `cy.mount()`\n\nUsing the [`cy.mount()`](/llm/markdown/api/commands/mount.md) command in a Cypress Component Test will render your component but does not affect the behavior of the page or window object. This means you can `mount` directly after calling `cy.clock()` to test the component against any changes you've made to the yielded clock object.\n",
      "section": "api",
      "anchors": [
        "clock-behavior-before-cy-mount"
      ],
      "path": "/llm/json/chunked/api/commands/clock.json",
      "token_estimate": 71
    },
    {
      "id": "api/commands/clock#clock-behavior-before-cy-visit",
      "doc_id": "api/commands/clock",
      "heading": "clock behavior before cy.visit()",
      "heading_level": 4,
      "content_markdown": "#### clock behavior before `cy.visit()`\n\nIf you call `cy.clock()` before visiting a page with [`cy.visit()`](/llm/markdown/api/commands/visit.md), the page's native global functions will be overridden on window load, before any of your app code runs. So even if `setTimeout`, for example, is called on page load, it can still be controlled via [`cy.tick()`](/llm/markdown/api/commands/tick.md). This also applies if, during the course of a test, the page under test is reloaded or changed.\n",
      "section": "api",
      "anchors": [
        "clock-behavior-before-cy-visit"
      ],
      "path": "/llm/json/chunked/api/commands/clock.json",
      "token_estimate": 92
    },
    {
      "id": "api/commands/clock#rules",
      "doc_id": "api/commands/clock",
      "heading": "Rules",
      "heading_level": 2,
      "content_markdown": "## Rules\n\n### Requirements [Learn about chaining commands](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Chains-of-Commands)\n\n*   `cy.clock()` requires being chained off of `cy`.\n\n### Assertions [Learn about assertions](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Assertions)\n\n*   `cy.clock()` is a utility command.\n*   `cy.clock()` will not run assertions. Assertions will pass through as if this command did not exist.\n\n### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)\n\n*   `cy.clock()` cannot time out.\n",
      "section": "api",
      "anchors": [
        "rules"
      ],
      "path": "/llm/json/chunked/api/commands/clock.json",
      "token_estimate": 72
    },
    {
      "id": "api/commands/clock#command-log",
      "doc_id": "api/commands/clock",
      "heading": "Command Log",
      "heading_level": 2,
      "content_markdown": "## Command Log\n\n**_Create a clock and tick it 1 second_**\n\n```\ncy.clock()cy.tick(1000)\n```\n\nThe command above will display in the Command Log as:\n\nWhen clicking on the `clock` command within the command log, the console outputs the following:\n",
      "section": "api",
      "anchors": [
        "command-log"
      ],
      "path": "/llm/json/chunked/api/commands/clock.json",
      "token_estimate": 52
    }
  ]
}