Lesson 9 : Error: Invalid Chai property: revertedWithCustomError #4129
Answered
by
SimSimButDifferent
JovanniChen
asked this question in
Q&A
-
This is happening with all of my custom errors. Whenever I expect the transaction to revert with these custom errors, it shows reverted with a custom error. /* errors */
error Raffle__EntranceFeeNotEnough();
error Raffle__TransferFailed();
error Raffle__NotOpen();
error Raffle__UpkeepNotNeeded(
uint256 currentBalance,
uint256 numPlayers,
uint256 raffleState
); Unit test: describe("enterRaffle", () => {
it("reverts when you don't pay enough part 1", async () => {
await expect(raffle.enterRaffle()).to.be.revertedWith(
"Raffle__EntranceFeeNotEnough"
)
})
it("reverts when you don't pay enough part 2", async () => {
await expect(
raffle.enterRaffle()
).to.be.revertedWithCustomError(
raffle,
"Raffle__EntranceFeeNotEnough"
)
})
it("records player when they enter", async () => {
await raffle.enterRaffle({ value: raffleEntranceFee })
const contractPlayer = await raffle.getPlayer(0)
assert.equal(deployer, contractPlayer)
})
}) And I got:
Someone can help me? Thanks. |
Beta Was this translation helpful? Give feedback.
Answered by
SimSimButDifferent
Dec 15, 2022
Replies: 1 comment 7 replies
-
Post your whole contract code or share repo please, ill have a look |
Beta Was this translation helpful? Give feedback.
7 replies
Answer selected by
JovanniChen
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Post your whole contract code or share repo please, ill have a look