Skip to content

Commit

Permalink
use flag to initialize chai-matchers only one
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherDedominici committed Dec 17, 2024
1 parent 76e8820 commit af84d41
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ import type {
import { addChaiMatchers } from "../add-chai-matchers.js";

export default async (): Promise<Partial<NetworkHooks>> => {
let isInitialized = false;

const handlers: Partial<NetworkHooks> = {
async newConnection<ChainTypeT extends ChainType | string>(
context: HookContext,
next: (context: HookContext) => Promise<NetworkConnection<ChainTypeT>>,
) {
addChaiMatchers();
if (!isInitialized) {
addChaiMatchers();
isInitialized = true;
}

return next(context);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import { createHardhatRuntimeEnvironment } from "@ignored/hardhat-vnext/hre";
import hardhatEthersPlugin from "@ignored/hardhat-vnext-ethers";
import { expect } from "chai";

import { addChaiMatchers } from "../src/internal/add-chai-matchers.js";

addChaiMatchers();
import hardhatChaiMatchersPlugin from "../src/index.js";

describe("handle multiple connections", () => {
let sender: HardhatEthersSigner;
Expand All @@ -30,7 +28,7 @@ describe("handle multiple connections", () => {

before(async () => {
const hre = await createHardhatRuntimeEnvironment({
plugins: [hardhatEthersPlugin],
plugins: [hardhatChaiMatchersPlugin, hardhatEthersPlugin],
networks: {
test1: {
type: "edr",
Expand Down

0 comments on commit af84d41

Please sign in to comment.