0 passing !! #1107
-
hi i am running my yarn hardhat test and i am gettin 0 passing when i run the code. i saw that patrick told other people to change file name from .tests to .test but this is not my case i already have it on .test . what could be the problem? no matter how many functions i include i keep on getting 0 passing. // unit tests bas lal development chains
const { assert, expect } = require("chai")
const { getNamedAccounts, deployments, ethers } = require("hardhat")
const { developmentChains, networkConfig } = require("../../helper-hardhat-config")
!developmentChains.includes(network.name)
? describe.skip
: describe("Raffle Unit Tests", async function () {
let raffle, vrfCoordinatorV2Mock
const chainId = network.Config.chainId
beforeEach(async function () {
const { deployer } = await getNamedAccounts()
await deployments.fixture(["all"])
raffle = await ethers.getContract("Raffle", deployer)
vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock", deployer)
})
describe("constructor", async function () {
it("Initializes the raffle correctly", async function () {
//ideallly we make our tests have just 1 assert per "it"
const raffleState = await raffle.getRaffleState()
const interval = await raffle.getInterval()
assert.equal(raffleState.toString(), "0")
assert.equal(interval.toString(), networkConfig[chainId]["interval"])
//bethot .to string eza its gna be a big number
})
})
describe("enterRaffle", async function () {
it("reverts when your don't pay enough", async function () {
await expect(raffle.enterRaffle()).to.be.revertedWith(
"Raffle__SendMoreToEnterRaffle"
)
})
})
}) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
@chrismogab First of all you should check whether the execution executes these tests or not. Add the console.log("with any message") to these tests and show the terminal. |
Beta Was this translation helpful? Give feedback.
-
Create a Folder "test" and inside it create another Folder "unit" and inside the unit folder create Raffle.test.js // unit tests bas lal development chains
const { assert, expect } = require("chai")
const { getNamedAccounts, deployments, ethers } = require("hardhat")
const { developmentChains, networkConfig } = require("../../helper-hardhat-config")
!developmentChains.includes(network.name)
? describe.skip
: describe("Raffle Unit Tests", async function () {
let raffle, vrfCoordinatorV2Mock
const chainId = network.Config.chainId
beforeEach(async function () {
const { deployer } = await getNamedAccounts()
await deployments.fixture(["all"])
raffle = await ethers.getContract("Raffle", deployer)
vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock", deployer)
})
describe("constructor", async function () {
it("Initializes the raffle correctly", async function () {
//ideallly we make our tests have just 1 assert per "it"
const raffleState = await raffle.getRaffleState()
const interval = await raffle.getInterval()
assert.equal(raffleState.toString(), "0")
assert.equal(interval.toString(), networkConfig[chainId]["interval"])
//bethot .to string eza its gna be a big number
})
})
describe("enterRaffle", async function () {
it("reverts when your don't pay enough", async function () {
await expect(raffle.enterRaffle()).to.be.revertedWith(
"Raffle__SendMoreToEnterRaffle"
)
})
})
}) |
Beta Was this translation helpful? Give feedback.
-
Hope this helps |
Beta Was this translation helpful? Give feedback.
const chainId = network.Config.chainId
typo, should be network.config.chainIdBoth the
getContract
functions should be getContractAtHope this helps