For AI agents: the complete documentation index is available at /zh/llms.txt, the full documentation bundle is available at /zh/llms-full.txt, and this page is available as Markdown at /zh/config/test/restore-mocks.md.
close
  • 简体中文
  • restoreMocks

    • 类型: boolean
    • 默认值: false
    • CLI: --restoreMocks

    在每个测试前恢复通过 rs.spyOn() 替换的对象方法。调用记录和 mock 实现会保留,通过 rs.fn() 创建的独立 mock 不受影响。

    当启用 restoreMocks 时,rstest 将在每个测试用例执行之前调用 .restoreAllMocks()。

    CLI
    rstest.config.ts
    npx rstest --restoreMocks