I'm trying to unit test my simple contract however, I don't know which way to do it.
For unit-testing should I create a new contract on beforeEach()
, so it runs before each it()
?
Using: new ethers.Contract()
Or should I interact with my hardhat already deployed contract with: getContractAt()
or getContract()?
Example:
describe("testing title", async () => {
let signers, TDM
beforeEach(async () => {
signers = ethers.getSigners()
TDMContract = await ethers.getContractAt(
"TokenDistrubutionMechanism",
contractAddress,
signers[0]
)
TDM = TDMContract.connect(signers[1])
})
it("constructor", async () => {
const name = await TDM.name()
assert.equal(name, "TokenDistrubutionMechanism")
})
})