For the complete documentation index, see llms.txt. This page is also available as Markdown.

Testing

exist test Directory to write tests for your smart contracts. For example,GreeterContract testing:

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

describe("Greeter", function () {

it("Should return the new greeting once it's changed", async function () {

const Greeter = await ethers.getContractFactory("Greeter");

const greeter = await Greeter.deploy("Hello, EMC!");

await greeter.deployed();

expect(await greeter.greet()).to.equal("Hello, EMC!");

const setGreetingTx = await greeter.setGreeting("Hola, EMC!");

await setGreetingTx.wait();

expect(await greeter.greet()).to.equal("Hola, EMC!");

});

});

Run the test:

npx hardhat test

Last updated