{
  "doc": {
    "id": "api/commands/tick",
    "title": "tick | Cypress Documentation",
    "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": "48b03b5502f7aea1d0454750cce208f775403542",
    "updated_at": "2026-05-20T19:00:20.270Z",
    "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-learn-about-subject-management",
        "text": "Yields Learn about subject management",
        "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-learn-about-chaining-commands",
        "text": "Requirements Learn about chaining commands",
        "level": 3
      },
      {
        "id": "api/commands/tick#assertions-learn-about-assertions",
        "text": "Assertions Learn about assertions",
        "level": 3
      },
      {
        "id": "api/commands/tick#timeouts-learn-about-timeouts",
        "text": "Timeouts Learn about 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 [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)\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": 192
    },
    {
      "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-learn-about-subject-management",
      "doc_id": "api/commands/tick",
      "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.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-learn-about-subject-management"
      ],
      "path": "/llm/json/chunked/api/commands/tick.json",
      "token_estimate": 89
    },
    {
      "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.htmlwindow.addIntro = () => {  setTimeout(() => {    document.getElementById('#header').textContent = 'Hello, World'  }, 500)}\n```\n\n```\ncy.clock()cy.visit('/index.html')cy.window().invoke('addIntro')cy.tick(500)cy.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()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": [
        "examples"
      ],
      "path": "/llm/json/chunked/api/commands/tick.json",
      "token_estimate": 157
    },
    {
      "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.htmlwindow.addIntro = () => {  setTimeout(() => {    document.getElementById('#header').textContent = 'Hello, World'  }, 500)}\n```\n\n```\ncy.clock()cy.visit('/index.html')cy.window().invoke('addIntro')cy.tick(500)cy.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": 72
    },
    {
      "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.htmlwindow.addIntro = () => {  setTimeout(() => {    document.getElementById('#header').textContent = 'Hello, World'  }, 500)}\n```\n\n```\ncy.clock()cy.visit('/index.html')cy.window().invoke('addIntro')cy.tick(500)cy.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": 49
    },
    {
      "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()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/tick.json",
      "token_estimate": 83
    },
    {
      "id": "api/commands/tick#rules",
      "doc_id": "api/commands/tick",
      "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.tick()` requires being chained off of `cy`.\n*   `cy.tick()` requires that `cy.clock()` be called before it.\n\n### Assertions [Learn about assertions](/llm/markdown/app/core-concepts/introduction-to-cypress.md#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 [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)\n\n*   `cy.tick()` cannot time out.\n",
      "section": "api",
      "anchors": [
        "rules"
      ],
      "path": "/llm/json/chunked/api/commands/tick.json",
      "token_estimate": 84
    },
    {
      "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()cy.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": 52
    }
  ]
}