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);
  • I'm struggling with this same problem. Did you ever find a solution? I have successfully overrided the subtask above and I can see the console log but I still get a 0 passing output.
    – Brandon
    Commented Mar 6, 2022 at 13:26
  • what is your folder structure? Commented Mar 7, 2022 at 17:12
  • Consider starting from my Hardhat template and you won't have this problem anymore. Commented Oct 3, 2022 at 13:23

13 Answers 13


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 () => {


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

    it("work", async () => {
        await ethers.getSigners()
  • That was my problem, although I exectued await ethers.getContract() in the descibe clause. That lead to the same problem! Commented Jun 22, 2022 at 12:29
  • Quite silly, ha? I don't see a reason why this shouldn't work.
    – Kof
    Commented Jun 25, 2022 at 6:39
  • Cannot think of a reason currently...whatever. You saved my day. Commented Jun 25, 2022 at 18:13
  • Has somebody opened up a bug for this? I ran into this too and it very clearly is a bug. This should not stop a test from running.
    – VoR0220
    Commented Jul 12, 2022 at 3:06
  • Another scenario where the same may happen is if the test folder wasn't created in the right place. E.g. I had created it as a sub-folder of ./contracts by mistake, instead of . .
    – Fanta
    Commented Jul 20, 2022 at 13:21

once upon a time, i wrote this, it should be "it", but i wrote "if". no error, just tip "0 passing",

describe("Token contract", function () {
    if("Deployment should assign the total supply of tokens to the owner", async function () {
        const [owner] = await ethers.getSigners();
        const Token = await ethers.getContractFactory("Token");
        const hardhatToken = await Token.deploy();
        const ownerBanlance = await hardhatToken.banlanceOf(owner.address);

        expect(await hardhatToken.totalSupply()).to.equal(ownerBanlance);

Try running npx hardhat clean and see if that helps.

Had the same issue after changing some filenames and variables and the above command fixed it.


yarn test will run the test script in your package.json: https://classic.yarnpkg.com/lang/en/docs/cli/test/

what I think you're actually trying to do is: npx hardhat test https://hardhat.org/guides/waffle-testing.html

  • tried that too but it doesnot seem to work as well. Commented Jan 17, 2022 at 7:45
  • Can you share your console output?
    – ori
    Commented Jan 17, 2022 at 17:47

I got it to work by overriding TASK_TEST_GET_TEST_FILES hardhat subtask which actually returns the files found for testing,

task(TASK_TEST_GET_TEST_FILES, async ({ testFiles }) => {
  const overriddenTestFiles = glob.sync("tests/**/*.test.ts");
  console.log(testFiles, overriddenTestFiles);
  return overriddenTestFiles;

Here I used glob to get all the test files in my test directory. (You can modify the pattern in your own way)

  • I just changed my testing architecture to be more scalable and it worked like a charm. Commented Jan 26, 2022 at 10:34
  • yeah it sometimes doesn't detect the new test files added
    – Noman
    Commented Jan 26, 2022 at 14:22
  • btw can you share your testing arch? (if there is no problem)
    – Noman
    Commented Jan 26, 2022 at 14:23
  • currently it is a private repo. Soon to be public, will share then Commented Jan 27, 2022 at 8:27

How I got it working:

  • Check ts.config includes. Mine didnt had test so I changed to ./test
  • Chcked my network config in hardhat.config.ts to have local host
  • Check folder structure to match ts.confg

Then changed these imports on my contract.spec.ts

// From this
// import { expect, use } from "chai";
// import { ethers } from "hardhat";
// import { solidity } from "ethereum-waffle";

// To this
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { expect, use } from "chai";
import { solidity } from "ethereum-waffle";

import hh, { ethers } from "hardhat";

import {
} from "../build/types";

    local: {
      url: "http://localhost:8545",
        process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
  "compilerOptions": {
    "target": "es2018",
    "module": "commonjs",
    "strict": true,
    "esModuleInterop": true,
    "outDir": "dist",
    "declaration": true,
    "resolveJsonModule": true
  "include": ["./scripts", "./test", "./typechain"],
  "files": ["./hardhat.config.ts"]

One possibility is your hardhat config is written in javascript format instead of typescript format.

As specified in hardhat doc:

Hardhat will automatically enable its TypeScript support if your config file ends in .ts and is written in valid TypeScript. This requires a few changes to work properly.

So if your test case is in typescript format but your hardhat config is in javascript format, 0 passing will be produced all the time.

Detailed behavior can be seen in test.js (code below found in hardhat v2.9.2):

const jsFiles = await glob(path.join(config.paths.tests, "**/*.js"));

if (!isRunningWithTypescript(config)) {
  return jsFiles;

const tsFiles = await glob(path.join(config.paths.tests, "**/*.ts"));

return [...jsFiles, ...tsFiles];

I had the same problem today. I installed the helmet after I created the folders tests, scripts, etc. The problem was that I created a tests folder instead of test. I don't know why, but hardhat didn't rename it and didn't create a new one, so it didn't see my tests. Check the name of your test folder, maybe you need to rename it.


Another cause for this issue is that the test folder is not located in the default location provided from hardhat. In details, Hardhat default configuration requires a folder called 'test' created in root of your project. If you change this folder name or location where you want to execute your tests, the program'll say that '0 passing'.

To solve this issue, in your hardhat.config.js you must specify new test folder path, adding the paths key and the new location inside tests key.


Location my Hardhat tests: {project_root_folder}/tests/smartcontract


module.exports = {
  solidity: {
    version: "0.8.0",
    settings: {
      optimizer: {
        enabled: true,
        runs: 200
  paths: {
    tests: "./tests/smartcontract"

I think you need to do yarn hardhat test. If this also doesn't work you can put following code into your hardhat config.

 paths: {
        tests: "./tests",

I got into the same problem your package name needs to be called "test" or you need to set specific path in hardhat config :)

  • Your answer does not provide any more useful information, as other (at least 2) answers say the same. Commented Jan 2, 2023 at 8:29

Try to rename hardhat.config.js -> hardhat.config.ts (from JavaScript to TypeScript!)


I faced the similar issue. What fixed it for me was that the anonymous function that "describe" and "it" take should be NOT be declared 'async' if there's no 'await' in its direct scope.

describe("something", () => {
    describe("something else", async () => {
        const {deployer} = await  getNamedAccounts();

Not the answer you're looking for? Browse other questions tagged or ask your own question.