lesson 15: TypeError: Cannot read properties of undefined (reading 'waitForTransaction') #3066
-
Got this error while writing test for NftMarketplace const { inputToConfig } = require("@ethereum-waffle/compiler")
const { assert, expect } = require("chai")
const { network, getNamedAccounts, deployments, ethers } = require("hardhat")
const { networkConfig, developmentChains } = require("../../helper-hardhat-config")
!developmentChains.includes(network.name)
? describe.skip
: describe("NFT Market place test", function () {
let nftMarketplace, nftMarketplaceContract, basicNft, basicNftContract
const PRICE = ethers.utils.parseEther("0.01")
const TOKEN_ID = 0
beforeEach(async function () {
const accounts = await ethers.getSigners()
deployer = accounts[0]
player = accounts[1]
await deployments.fixture(["all"])
nftMarketplaceContract = await ethers.getContract("NftMarketplace")
nftMarketplace = nftMarketplaceContract.connect(deployer)
basicNftContract = await ethers.getContract("BasicNft")
basicNft = basicNftContract.connect(deployer)
await basicNft.mintNft()
await basicNft.approve(nftMarketplaceContract.address, TOKEN_ID)
})
describe("listItems", function () {
it("reverts if NFT is Alredy Listed", async function () {
await nftMarketplaceContract.listItem(basicNftContract.address, TOKEN_ID, PRICE)
await expect(
nftMarketplaceContract.listItem(basicNftContract.address, TOKEN_ID, PRICE)
).to.be.revertedWith("NftMarketPlace__AlreadyListed")
})
it("reverts if lister is not owner of the NFT", async function () {
await basicNft.mintNft()
await expect(
nftMarketplaceContract
.connect(player)
.listItem(basicNftContract.address, TOKEN_ID, PRICE)
).to.be.revertedWith("NftMarketPlace__NotOwner")
})
it("reverts when price is less than or equal to zero", async function () {
await expect(
nftMarketplaceContract.listItem(basicNftContract.address, TOKEN_ID, 0)
).to.be.revertedWith("NftMarketPlace__PriceMustBeAboveZero")
})
it("reverts when our contract is not approved by NFT Contract", async function () {
await basicNft.approve(ethers.constants.AddressZero, TOKEN_ID)
await expect(
nftMarketplace.listItem(basicNft.address, TOKEN_ID, PRICE)
).to.be.revertedWith("NotApprovedForMarketplace")
})
it("adds NFT to listing mapping", async function () {
await nftMarketplace.listItem(basicNftContract.address, TOKEN_ID, PRICE)
const listing = await nftMarketplace.getListing(basicNft.address, TOKEN_ID)
// assert(listing)
assert.equal(listing.price.toString(), PRICE.toString())
assert.equal(listing.seller.toString(), deployer.address)
})
it("emits an event after listing an item", async function () {
expect(await nftMarketplace.listItem(basicNft.address, TOKEN_ID, PRICE)).to.emit(
"ItemListed"
)
})
})
}) Here's the error: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Got it First line was creating problem I don't how it got there |
Beta Was this translation helpful? Give feedback.
Got it First line was creating problem I don't how it got there