solidity – How to Fix 0 Passing Tests Issue in Hardhat Environment

chaietherhardhatmochasolidity

I am facing rather unusual behavior from hardhat. I have written my test cases in a file inside test folder when i run yarn teston the terminal it gives me 0 passing. Don't have any idea as to why it may be happening. there are two it statements inside my describe wrapper. Following is my testcase

describe("Initializing the testing suite", async () => {
  it("checking name of vault LP Token", async () => {
     const vaultLPName = (await vault.name()).toString();
     console.log("Vault LP name", vaultLPName);
     expect(vaultLPName).to.be.equal("eth-usdt");
  });
}

Best Answer

This can happen if await ethers.getSigners() is executed in describe clause.

Example that doesn't work (0 passing):

describe("ContractName", async () => {

    await ethers.getSigners()

    it("work", async () => {
        ...
    });

Fixed:

describe("ContractName", async () => {

    it("work", async () => {
        await ethers.getSigners()
        ...
    });
Related Topic