0

I am working with patrick solidity course on youtube and have gotten to the point of carrying out unit testing. I am having this issue enter image description here

getting this error

enter image description here

const { assert, expect } = require("chai");
const { deployments, ethers, getNamedAccounts } = require("hardhat");
require("@nomicfoundation/hardhat-toolbox");
require("@nomicfoundation/hardhat-verify");
require("hardhat-gas-reporter");
require("hardhat-deploy");
require("@nomicfoundation/hardhat-ethers");
require("hardhat-deploy-ethers");
require("dotenv").config();

describe("FundMe", async function () {
  let fundMe;
  let deployer;
  let MockV3Aggregator;
  beforeEach(async () => {
    deployer = (await getNamedAccounts()).deployer;
    await deployments.fixture(["all"]);
    fundMe = await ethers.getContract("FundMe", deployer); //deploy the lastest version of the fundme contract with the harhhat deployer account
    mockV3Aggegator = await ethers.getContract("MockV3Aggregator", deployer);
  });

  describe("constructor", function () {
    it("sets the aggregator addresses correctly", async () => {
      const response = await fundMe.priceFeed();
      assert.equal(response, mockV3Aggegator.address);
    });
  });
  describe("fund", function () {
    it("fails if you dont send enough ETH", async () => {
      await expect(fundMe.fund()).to.be.revertedWith(
        "You need to spend more ETH"
      );
    });
  });
});

from the research I have done I feel its from hardhat chai. Please help thank you in advance

error msg

yarn run v1.22.19
warning package.json: No license field
$ /Users/eric/Documents/hardhat/hardhat-fund-me/node_modules/.bin/hardhat test


  FundMe
    constructor
      ✔ sets the aggregator addresses correctly
    fund
      1) fails if you dont send enough ETH


  1 passing (604ms)
  1 failing

  1) FundMe
       fund
         fails if you dont send enough ETH:
     TypeError: AbiCoder is not a constructor
      at decodeReturnData (node_modules/@nomicfoundation/hardhat-chai-matchers/src/internal/reverted/utils.ts:65:15)
      at onError (node_modules/@nomicfoundation/hardhat-chai-matchers/src/internal/reverted/revertedWith.ts:45:51)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at runNextTicks (node:internal/process/task_queues:64:3)
      at listOnTimeout (node:internal/timers:538:9)
      at processTimers (node:internal/timers:512:7)
      at Context.<anonymous> (test/FundMe.test.js:30:7)



error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
1
  • 1
    Please, can you provide the code as text.
    – Ismael
    Aug 7, 2023 at 0:58

0

Your Answer

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