0

.js file

const { expect } = require('chai');

describe("Token contract",function(){
it("Deployment should assign the total supply of the owner", async function(){
    const[owner] = await ethers.getSigners();

    console.log("Signers Object:",owner);
    const Token = await ethers.getContractFactory("Token");//instance contract

    const hardhatToken = await Token.deploy(); //deploy

    const ownerBalance = await hardhatToken.balanceOf(owner.address);//ownerBalance = 10000
    console.log("Owner Address:",owner.address);

    expect(await hardhatToken.totalSupply()).to.equal(ownerBalance)// total supply=10000

});
});
 

Package.json

  {
    "name": "testinghardhat",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
       "test": "echo \"Error: no test specified\" && exit 1"
  },
        "author": "",
        "license": "ISC",
         "devDependencies": {
         "@nomiclabs/hardhat-ethers": "^2.2.3",
        "@nomiclabs/hardhat-waffle": "^2.0.6",
        "chai": "^5.0.3",
        "ethereum-waffle": "^4.0.10",
        "ethers": "^5.7.2",
        "hardhat": "^2.19.4"
  },
       "dependencies": {
            "glob": "^7.2.0",
            "node-fetch": "^2.6.6"
   }
}

1 Answer 1

0

try using earlier "chai" version, for example, do yarn add --dev [email protected] or npm i --save-dev [email protected], depending on your package manager. It worked well for me.

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.