{
  "doc": {
    "id": "api/commands/tick",
    "title": "cy.tick()",
    "description": "Move time after overriding a native time function with `cy.clock()` in Cypress.",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/tick.md",
    "version": "f97f06d85653c51afe39a9bd3cefda946807f150",
    "updated_at": "2026-10-05T21:01:45.863Z",
    "headings": [
      {
        "id": "api/commands/tick#tick",
        "text": "tick",
        "level": 1
      },
      {
        "id": "api/commands/tick#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/commands/tick#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/commands/tick#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/commands/tick#yields",
        "text": "Yields",
        "level": 3
      },
      {
        "id": "api/commands/tick#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/commands/tick#milliseconds",
        "text": "Milliseconds",
        "level": 3
      },
      {
        "id": "api/commands/tick#create-a-clock-and-move-time-to-trigger-a-settimeout",
        "text": "Create a clock and move time to trigger a setTimeout",
        "level": 4
      },
      {
        "id": "api/commands/tick#using-cy-clock-with-cy-tick",
        "text": "Using cy.clock() with cy.tick()",
        "level": 4
      },
      {
        "id": "api/commands/tick#restore-clock",
        "text": "Restore clock",
        "level": 3
      },
      {
        "id": "api/commands/tick#rules",
        "text": "Rules",
        "level": 2
      },
      {
        "id": "api/commands/tick#requirements",
        "text": "Requirements",
        "level": 3
      },
      {
        "id": "api/commands/tick#assertions",
        "text": "Assertions",
        "level": 3
      },
      {
        "id": "api/commands/tick#timeouts",
        "text": "Timeouts",
        "level": 3
      },
      {
        "id": "api/commands/tick#command-log",
        "text": "Command Log",
        "level": 2
      },
      {
        "id": "api/commands/tick#history",
        "text": "History",
        "level": 2
      },
      {
        "id": "api/commands/tick#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "chunks": [
    {
      "id": "api/commands/tick#syntax",
      "doc_id": "api/commands/tick",
      "heading": "Syntax",
      "heading_level": 2,
      "content_markdown": "## Syntax\n\n```\ncy.tick(milliseconds, options)\n```\n\n### Usage\n\n**Correct Usage**\n\n```\ncy.tick(500)\n```\n\n### Arguments\n\n**milliseconds _(Number)_**\n\nThe number of `milliseconds` to move the clock. Any timers within the affected range of time will be called.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `cy.tick()`.\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\n\n`cy.tick()` yields a `clock` object with the following methods:\n\n*   **`clock.tick(milliseconds)`**\n    \n    Move the clock a 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\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/tick.json",
      "token_estimate": 187
    },
    {
      "id": "api/commands/tick#arguments",
      "doc_id": "api/commands/tick",
      "heading": "Arguments",
      "heading_level": 3,
      "content_markdown": "### Arguments\n\n**milliseconds _(Number)_**\n\nThe number of `milliseconds` to move the clock. Any timers within the affected range of time will be called.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `cy.tick()`.\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/tick.json",
      "token_estimate": 85
    },
    {
      "id": "api/commands/tick#yields",
      "doc_id": "api/commands/tick",
      "heading": "Yields",
      "heading_level": 3,
      "content_markdown": "### Yields\n\n`cy.tick()` yields a `clock` object with the following methods:\n\n*   **`clock.tick(milliseconds)`**\n    \n    Move the clock a 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\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"
      ],
      "path": "/llm/json/chunked/api/commands/tick.json",
      "token_estimate": 84
    },
    {
      "id": "api/commands/tick#examples",
      "doc_id": "api/commands/tick",
      "heading": "Examples",
      "heading_level": 2,
      "content_markdown": "## Examples\n\n### Milliseconds\n\n#### Create a clock and move time to trigger a `setTimeout`\n\n```\n// app code loaded by index.html\nwindow.addIntro = () => {\n  setTimeout(() => {\n    document.getElementById('#header').textContent = 'Hello, World'\n  }, 500)\n}\n```\n\n```\ncy.clock()\ncy.visit('/index.html')\ncy.window().invoke('addIntro')\ncy.tick(500)\ncy.get('#header').should('have.text', 'Hello, World')\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()\ncy.visit('http://localhost:3333')\ncy.get('#search').type('Acme Company')\ncy.tick(1000)\n// more test code here\n\n// restore the clock\ncy.clock().then((clock) => {\n  clock.restore()\n})\n// 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": [
        "examples"
      ],
      "path": "/llm/json/chunked/api/commands/tick.json",
      "token_estimate": 176
    },
    {
      "id": "api/commands/tick#milliseconds",
      "doc_id": "api/commands/tick",
      "heading": "Milliseconds",
      "heading_level": 3,
      "content_markdown": "### Milliseconds\n\n#### Create a clock and move time to trigger a `setTimeout`\n\n```\n// app code loaded by index.html\nwindow.addIntro = () => {\n  setTimeout(() => {\n    document.getElementById('#header').textContent = 'Hello, World'\n  }, 500)\n}\n```\n\n```\ncy.clock()\ncy.visit('/index.html')\ncy.window().invoke('addIntro')\ncy.tick(500)\ncy.get('#header').should('have.text', 'Hello, World')\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": [
        "milliseconds"
      ],
      "path": "/llm/json/chunked/api/commands/tick.json",
      "token_estimate": 80
    },
    {
      "id": "api/commands/tick#create-a-clock-and-move-time-to-trigger-a-settimeout",
      "doc_id": "api/commands/tick",
      "heading": "Create a clock and move time to trigger a setTimeout",
      "heading_level": 4,
      "content_markdown": "#### Create a clock and move time to trigger a `setTimeout`\n\n```\n// app code loaded by index.html\nwindow.addIntro = () => {\n  setTimeout(() => {\n    document.getElementById('#header').textContent = 'Hello, World'\n  }, 500)\n}\n```\n\n```\ncy.clock()\ncy.visit('/index.html')\ncy.window().invoke('addIntro')\ncy.tick(500)\ncy.get('#header').should('have.text', 'Hello, World')\n```\n",
      "section": "api",
      "anchors": [
        "create-a-clock-and-move-time-to-trigger-a-settimeout"
      ],
      "path": "/llm/json/chunked/api/commands/tick.json",
      "token_estimate": 57
    },
    {
      "id": "api/commands/tick#restore-clock",
      "doc_id": "api/commands/tick",
      "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()\ncy.visit('http://localhost:3333')\ncy.get('#search').type('Acme Company')\ncy.tick(1000)\n// more test code here\n\n// restore the clock\ncy.clock().then((clock) => {\n  clock.restore()\n})\n// 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/tick.json",
      "token_estimate": 93
    },
    {
      "id": "api/commands/tick#rules",
      "doc_id": "api/commands/tick",
      "heading": "Rules",
      "heading_level": 2,
      "content_markdown": "## Rules\n\n### Requirements\n\n*   `cy.tick()` requires being chained off of `cy`.\n*   `cy.tick()` requires that `cy.clock()` be called before it.\n\n### Assertions\n\n*   `cy.tick()` is a utility command.\n*   `cy.tick()` will not run assertions. Assertions will pass through as if this command did not exist.\n\n### Timeouts\n\n*   `cy.tick()` cannot time out.\n",
      "section": "api",
      "anchors": [
        "rules"
      ],
      "path": "/llm/json/chunked/api/commands/tick.json",
      "token_estimate": 71
    },
    {
      "id": "api/commands/tick#command-log",
      "doc_id": "api/commands/tick",
      "heading": "Command Log",
      "heading_level": 2,
      "content_markdown": "## Command Log\n\n**_Create a clock and tick it 1 second_**\n\n```\ncy.clock()\ncy.tick(1000)\n```\n\nThe command above will display in the Command Log as:\n\nWhen clicking on the `tick` command within the command log, the console outputs the following:\n",
      "section": "api",
      "anchors": [
        "command-log"
      ],
      "path": "/llm/json/chunked/api/commands/tick.json",
      "token_estimate": 53
    }
  ]
}