Lesson 9 lottery contract unit Testing error #2686
Answered
by
othaime-en
soumalya340
asked this question in
Q&A
-
I have written a unit test for unit watching the video and running and having error const { assert, expect } = require("chai")
const { deployments, ethers, getNamedAccounts, network } = require("hardhat")
const { developmentChain, networkConfig } = require("../../helper-hardhat-config.js")
!developmentChain.includes(network.name)
? describe.skip
: describe("Raffle", async function () {
let raffle, vrfCoordinatorMock
const chainId = network.config.chainId
beforeEach(async function () {
const { deployer } = await getNamedAccounts()
await deployments.fixture(["all"])
console.log("Hi")
raffle = new ethers.getContract("Raffle", deployer)
vrfCoordinatorMock = new ethers.getContract("VRFCoordinatorV2Mock", deployer)
})
describe("Constructor", async function () {
it("It intializes the raffle correctly", async function () {
const raffleState = await raffle.getRaffleState()
const interval = await raffle.getInterval()
assert.equal(raffleState.toString(), "0")
assert.equal(interval.toString(), networkConfig[chainId]["interval"])
})
})
}) |
Beta Was this translation helpful? Give feedback.
Answered by
othaime-en
Sep 18, 2022
Replies: 3 comments 15 replies
-
@soumalya340 What error? |
Beta Was this translation helpful? Give feedback.
10 replies
-
Hey @soumalya340 replace raffle = new ethers.getContract("Raffle", deployer)
vrfCoordinatorMock = new ethers.getContract("VRFCoordinatorV2Mock", deployer) It should be raffle = await ethers.getContract("Raffle", deployer)
vrfCoordinatorMock = await ethers.getContract("VRFCoordinatorV2Mock", deployer) |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
soumalya340
-
Thanks @othaime-en and @abossofmyself for the help |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @soumalya340 replace
new
withawait
in the lines belowIt should be