---
id: api/utilities/sinon
title: Cypress.sinon
description: Cypress automatically includes Sinon.JS and exposes it as Cypress.sinon.
section: api
source_path: docs/api/utilities/sinon.mdx
version: 48b03b5502f7aea1d0454750cce208f775403542
updated_at: '2026-05-20T19:00:20.270Z'
---
# Cypress.sinon

Cypress automatically includes [Sinon.JS](http://sinonjs.org/) and exposes it as `Cypress.sinon`. Because commands [`cy.spy`](/llm/markdown/api/commands/spy.md) and [`cy.stub`](/llm/markdown/api/commands/stub.md) are already wrapping Sinon methods, the most common use for `Cypress.sinon` is to provide flexible [matchers](https://sinonjs.org/releases/latest/matchers/) when doing assertions.

## Syntax

```
Cypress.sinon.match(value)Cypress.sinon.match.<matcher name>
```

### Usage

**Correct Usage**

```
Cypress.sinon.match.string
```

**Incorrect Usage**

```
cy.sinon.match.string // Errors, cannot be chained off 'cy'
```

## Examples

### `match.string`

This example comes from the recipe [Root style](https://github.com/cypress-io/cypress-example-recipes#testing-the-dom). Imagine an application code where the method `setProperty` is called to change a CSS variable:

```
document.querySelector('input[type=color]').addEventListener('change', (e) => {  document.documentElement.style.setProperty(    '--background-color',    e.target.value  )})
```

We can write a test to confirm that the method `setProperty` was called with two strings; we don't care about value of the first string, but we do want to check if it was indeed a string.

```
cy.document()  .its('documentElement.style')  .then((style) => {    cy.spy(style, 'setProperty').as('setColor')  })cy.get('input[type=color]').invoke('val', '#ff0000').trigger('change')// we don't care about '--background-color' exact// value but know it should be a stringcy.get('@setColor').should(  'have.been.calledWith',  Cypress.sinon.match.string,  '#ff0000')
```

## See also

*   [Spies, stubs & clocks](https://example.cypress.io/commands/spies-stubs-clocks) example page
*   [Sinon matchers](https://sinonjs.org/releases/latest/matchers/) documentation page
*   [Bundled Libraries](/llm/markdown/app/references/bundled-libraries.md)
*   [`cy.spy()`](/llm/markdown/api/commands/spy.md)
*   [`cy.stub()`](/llm/markdown/api/commands/stub.md)
*   [Stubs, Spies, and Clocks](/llm/markdown/app/guides/stubs-spies-and-clocks.md) guide
