(path: string | Promise<unknown>, factory?: MockOptions | MockFactoryWithHelper)
| 660 | }, |
| 661 | |
| 662 | doMock(path: string | Promise<unknown>, factory?: MockOptions | MockFactoryWithHelper) { |
| 663 | if (typeof path !== 'string') { |
| 664 | throw new TypeError( |
| 665 | `vi.doMock() expects a string path, but received a ${typeof path}`, |
| 666 | ) |
| 667 | } |
| 668 | const importer = getImporter('doMock') |
| 669 | _mocker().queueMock( |
| 670 | path, |
| 671 | importer, |
| 672 | typeof factory === 'function' |
| 673 | ? () => |
| 674 | factory(() => |
| 675 | _mocker().importActual( |
| 676 | path, |
| 677 | importer, |
| 678 | _mocker().getMockContext().callstack, |
| 679 | ), |
| 680 | ) |
| 681 | : factory, |
| 682 | ) |
| 683 | |
| 684 | const rv = {} as Disposable |
| 685 | if (Symbol.dispose) { |
| 686 | rv[Symbol.dispose] = () => { |
| 687 | _mocker().queueUnmock(path, importer) |
| 688 | } |
| 689 | } |
| 690 | return rv |
| 691 | }, |
| 692 | |
| 693 | doUnmock(path: string | Promise<unknown>) { |
| 694 | if (typeof path !== 'string') { |
nothing calls this directly
no test coverage detected
searching dependent graphs…