I know ethers.getContractFactory is a function so am wondering what am missing. Maybe importing something?
Environment
Truffle v5.1.67 (core: 5.1.67)
Solidity v0.5.16 (solc-js)
Node v12.19.0
Web3.js v1.2.9
Details
Code to reproduce
Here is the first part of the code, everything seems ok, no?
const { expect } = require('chai');
const { ethers } = require('ethers');
describe('Token contract', () => {
let Token, token, owner, addr1, addr2;
beforeEach(async () => {
Token = await ethers.getContractFactory("Token");
token = await Token.deploy();
[owner, addr1, addr2, _] = await ethers.getSigners();
});
describe('Deployment', () => {
it('Should set the right owner', async () => {
expect(await token.owner()).to.equal(owner.address);
});
it('Should assign the total supply of tokens to the owner', async () => {
const ownerBalance = await token.balanceOf(owner.address);
expect(await token.totalSupply()).to.equal(ownerBalance);
});
})