0

If I run yarn hardhat test. I'm getting this error:

yarn run v1.22.19
warning ../../../package.json: No license field
$ /Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/.bin/hardhat test
Compiled 8 Solidity files successfully (evm targets: istanbul, paris).

  Lock
    Deployment

      1) Should set the right unlockTime

      2) Should set the right owner

      3) Should receive and store the funds to lock

      4) Should fail if the unlockTime is not in the future
    Withdrawals
      Validations

        5) Should revert with the right error if called too soon

        6) Should revert with the right error if called from another account

        7) Shouldn't fail if the unlockTime has arrived and the owner calls it
      Events

        8) Should emit an event on withdrawals
      Transfers

        9) Should transfer the funds to the owner

  FuneMe
    constructor

      10) "before each" hook for "sets the aggregator addresses correctly"


  0 passing (736ms)
  10 failing

  1) Lock
       Deployment
         Should set the right unlockTime:
     HardhatError: HH700: Artifact for contract "Lock" not found. 
      at Artifacts._handleWrongArtifactForContractName (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:733:11)
      at Artifacts._getArtifactPathFromFiles (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:864:19)
      at Artifacts._getArtifactPath (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:522:21)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at Artifacts.readArtifact (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:71:26)
      at getContractFactory (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/@nomicfoundation/hardhat-ethers/src/internal/helpers.ts:107:22)
      at deployOneYearLockFixture (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/test/Lock.js:22:18)
      at loadFixture (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/@nomicfoundation/hardhat-network-helpers/src/loadFixture.ts:59:18)
      at Context.<anonymous> (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/test/Lock.js:30:36)

  2) Lock
       Deployment
         Should set the right owner:
     HardhatError: HH700: Artifact for contract "Lock" not found. 
      at Artifacts._handleWrongArtifactForContractName (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:733:11)
      at Artifacts._getArtifactPathFromFiles (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:864:19)
      at Artifacts._getArtifactPath (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:522:21)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at Artifacts.readArtifact (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:71:26)
      at getContractFactory (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/@nomicfoundation/hardhat-ethers/src/internal/helpers.ts:107:22)
      at deployOneYearLockFixture (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/test/Lock.js:22:18)
      at loadFixture (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/@nomicfoundation/hardhat-network-helpers/src/loadFixture.ts:59:18)
      at Context.<anonymous> (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/test/Lock.js:36:31)

  3) Lock
       Deployment
         Should receive and store the funds to lock:
     HardhatError: HH700: Artifact for contract "Lock" not found. 
      at Artifacts._handleWrongArtifactForContractName (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:733:11)
      at Artifacts._getArtifactPathFromFiles (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:864:19)
      at Artifacts._getArtifactPath (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:522:21)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at Artifacts.readArtifact (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:71:26)
      at getContractFactory (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/@nomicfoundation/hardhat-ethers/src/internal/helpers.ts:107:22)
      at deployOneYearLockFixture (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/test/Lock.js:22:18)
      at loadFixture (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/@nomicfoundation/hardhat-network-helpers/src/loadFixture.ts:59:18)
      at Context.<anonymous> (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/test/Lock.js:42:38)

  4) Lock
       Deployment
         Should fail if the unlockTime is not in the future:
     HardhatError: HH700: Artifact for contract "Lock" not found. 
      at Artifacts._handleWrongArtifactForContractName (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:733:11)
      at Artifacts._getArtifactPathFromFiles (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:864:19)
      at Artifacts._getArtifactPath (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:522:21)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at Artifacts.readArtifact (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:71:26)
      at getContractFactory (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/@nomicfoundation/hardhat-ethers/src/internal/helpers.ts:107:22)
      at Context.<anonymous> (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/test/Lock.js:54:20)

  5) Lock
       Withdrawals
         Validations
           Should revert with the right error if called too soon:
     HardhatError: HH700: Artifact for contract "Lock" not found. 
      at Artifacts._handleWrongArtifactForContractName (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:733:11)
      at Artifacts._getArtifactPathFromFiles (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:864:19)
      at Artifacts._getArtifactPath (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:522:21)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at Artifacts.readArtifact (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:71:26)
      at getContractFactory (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/@nomicfoundation/hardhat-ethers/src/internal/helpers.ts:107:22)
      at deployOneYearLockFixture (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/test/Lock.js:22:18)
      at loadFixture (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/@nomicfoundation/hardhat-network-helpers/src/loadFixture.ts:59:18)
      at Context.<anonymous> (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/test/Lock.js:64:26)

  6) Lock
       Withdrawals
         Validations
           Should revert with the right error if called from another account:
     HardhatError: HH700: Artifact for contract "Lock" not found. 
      at Artifacts._handleWrongArtifactForContractName (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:733:11)
      at Artifacts._getArtifactPathFromFiles (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:864:19)
      at Artifacts._getArtifactPath (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:522:21)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at Artifacts.readArtifact (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:71:26)
      at getContractFactory (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/@nomicfoundation/hardhat-ethers/src/internal/helpers.ts:107:22)
      at deployOneYearLockFixture (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/test/Lock.js:22:18)
      at loadFixture (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/@nomicfoundation/hardhat-network-helpers/src/loadFixture.ts:59:18)
      at Context.<anonymous> (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/test/Lock.js:72:52)

  7) Lock
       Withdrawals
         Validations
           Shouldn't fail if the unlockTime has arrived and the owner calls it:
     HardhatError: HH700: Artifact for contract "Lock" not found. 
      at Artifacts._handleWrongArtifactForContractName (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:733:11)
      at Artifacts._getArtifactPathFromFiles (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:864:19)
      at Artifacts._getArtifactPath (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:522:21)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at Artifacts.readArtifact (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:71:26)
      at getContractFactory (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/@nomicfoundation/hardhat-ethers/src/internal/helpers.ts:107:22)
      at deployOneYearLockFixture (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/test/Lock.js:22:18)
      at loadFixture (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/@nomicfoundation/hardhat-network-helpers/src/loadFixture.ts:59:18)
      at Context.<anonymous> (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/test/Lock.js:86:38)

  8) Lock
       Withdrawals
         Events
           Should emit an event on withdrawals:
     HardhatError: HH700: Artifact for contract "Lock" not found. 
      at Artifacts._handleWrongArtifactForContractName (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:733:11)
      at Artifacts._getArtifactPathFromFiles (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:864:19)
      at Artifacts._getArtifactPath (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:522:21)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at Artifacts.readArtifact (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:71:26)
      at getContractFactory (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/@nomicfoundation/hardhat-ethers/src/internal/helpers.ts:107:22)
      at deployOneYearLockFixture (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/test/Lock.js:22:18)
      at loadFixture (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/@nomicfoundation/hardhat-network-helpers/src/loadFixture.ts:59:18)
      at Context.<anonymous> (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/test/Lock.js:99:52)

  9) Lock
       Withdrawals
         Transfers
           Should transfer the funds to the owner:
     HardhatError: HH700: Artifact for contract "Lock" not found. 
      at Artifacts._handleWrongArtifactForContractName (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:733:11)
      at Artifacts._getArtifactPathFromFiles (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:864:19)
      at Artifacts._getArtifactPath (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:522:21)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at Artifacts.readArtifact (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/artifacts.ts:71:26)
      at getContractFactory (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/@nomicfoundation/hardhat-ethers/src/internal/helpers.ts:107:22)
      at deployOneYearLockFixture (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/test/Lock.js:22:18)
      at loadFixture (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/@nomicfoundation/hardhat-network-helpers/src/loadFixture.ts:59:18)
      at Context.<anonymous> (/Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/test/Lock.js:113:59)

  10) FuneMe
       "before each" hook for "sets the aggregator addresses correctly":
     TypeError: ethers.getContract is not a function
      at Context.<anonymous> (test/unit/FundMe.test.js:11:31)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at runNextTicks (node:internal/process/task_queues:64:3)
      at listOnTimeout (node:internal/timers:533:9)
      at processTimers (node:internal/timers:507:7)



error Command failed with exit code 10.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

My FundMe.test.js file:

const { deployments, ethers, getNamedAccounts } = require("hardhat"); // runtime environment..
const { assert } = require("chai");

describe("FundMe", async function () {
    let fundMe;
    let deployer;
    let mockV3Aggregator;
    beforeEach(async function () {
        deployer = (await getNamedAccounts()).deployer;
        await deployments.fixture(["all"]);
        fundMe = await ethers.getContract("FundMe", deployer);
        mockV3Aggregator = await ethers.getContract(
            "MockV3Aggregator",
            deployer
        );
    });

    describe("constructor", async function () {
        it("sets the aggregator addresses correctly", async function () {
            const response = await fundMe.priceFeed();
            assert.equal(response, mockV3Aggregator.address);
        });
    });
});

My code repo: https://github.com/Aideepakchaudhary/hardhat-fund-me

1 Answer 1

2

When you write npx hardhat test it simply runs the files inside the test folder. You need to mention the path of the test file you are trying to run. In this case npx hardhat test .\test\unit\FundMe.test.js, otherwise it also runs the Lock.js file.

enter image description here

Also, remove the Lock.js file as it's only a template and not needed for development.

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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