···1559155915601560## returned <Version>4.1.0</Version> {#returned}
1561156115621562-- **Type:** `Assertion` (property, not a method)
15621562+- **Type:** `(value: any) => void`
1563156315641564-Chai-style assertion that checks if a spy returned successfully at least once. This is equivalent to `toHaveReturned()`.
15651565-15661566-::: tip
15671567-This is a property assertion following sinon-chai conventions. Access it without parentheses: `expect(spy).to.have.returned`
15681568-:::
15641564+Chai-style assertion that checks if a spy returned a specific value at least once. This is equivalent to `toHaveReturnedWith(value)`.
1569156515701566```ts
15711567import { expect, test, vi } from 'vitest'
1572156815731569test('spy returned', () => {
15741574- const spy = vi.fn(() => 'result')
15701570+ const spy = vi.fn(() => 'value')
1575157115761572 spy()
1577157315781578- expect(spy).to.have.returned
15741574+ expect(spy).to.have.returned('value')
15791575})
15801576```
15811577
+1-2
docs/guide/migration.md
···742742| `spy.callCount(n)` | `callCount(n)` | Spy was called n times |
743743| `spy.calledWith(...)` | `calledWith(...)` | Spy was called with specific args |
744744| `spy.calledOnceWith(...)` | `calledOnceWith(...)` | Spy was called once with specific args |
745745-| `spy.returned` | `returned` | Spy returned successfully |
746746-| `spy.returnedWith(value)` | `returnedWith(value)` | Spy returned specific value |
745745+| `spy.returned(value)` | `returned` | Spy returned specific value |
747746748747See the [Chai-Style Spy Assertions](/api/expect#chai-style-spy-assertions) documentation for the complete list.
749748
···836836 nthCalledWith: <E extends any[]>(n: number, ...args: E) => void
837837838838 /**
839839- * Checks that a spy returned successfully at least once.
840840- * Chai-style equivalent of `toHaveReturned`.
839839+ * Checks that a spy returned a specific value at least once.
840840+ * Chai-style equivalent of `toHaveReturnedWith`.
841841 *
842842 * @example
843843- * expect(spy).to.have.returned
843843+ * expect(spy).to.have.returned('value')
844844 */
845845- readonly returned: Assertion
845845+ returned: <E>(value: E) => void
846846847847 /**
848848 * Checks that a spy returned a specific value at least once.