Skip to content

Commit

Permalink
feat: add doNotUseFetch helper to the test utils
Browse files Browse the repository at this point in the history
  • Loading branch information
galargh committed Sep 27, 2024
1 parent 57f9e87 commit 6b68734
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
16 changes: 16 additions & 0 deletions v-next/hardhat-test-utils/src/global.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { after, before } from "node:test";

export function doNotUseFetch(): void {
let originalFetch: typeof global.fetch;

before(async () => {
originalFetch = global.fetch;
global.fetch = async () => {
throw new Error("Network requests are disabled");
};
});

after(async () => {
global.fetch = originalFetch;
});
}
3 changes: 2 additions & 1 deletion v-next/hardhat-test-utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./fixture-projects.js";
export * from "./hardhat-error.js";
export * from "./fs.js";
export * from "./global.js";
export * from "./hardhat-error.js";

0 comments on commit 6b68734

Please sign in to comment.