FundMe "before each" hook for "sets the aggregator addresses correctly": Error: No Contract deployed with name FundMe #3287
-
Hey guys I am experiencing a problem on the first part of the unit test of HardHat-fundMe. When I run my FundMe.test.js I am getting the following output with error. mind you I have run it both on the hardhat network and the localhost. Also the deploy scripts work fine when i run yarn hardhat deploy. The problem only arises when I try to deploy the contracts from the unit test script. I have seen similar questions but none of the fixes have worked for me. I triple checked that both deploy scripts export the tags properly, I checked the hardhat config file 10 times for any bugs, as I said before I deployed the contracts just with the deploy scripts and it worked fine on both hardhat and localhost. I am pretty sure the problem lies in the line: The error i get:
Here is the FundMe.test.js
Here is my 00-deploy-mocks.js
Here is the 01-deploy-fund-me.js:
And here is my hardhat.config.js file :
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 11 replies
-
hello @jacoboforero make the following change in your test script:
After that change your test should able to pick up all scripts with the tag |
Beta Was this translation helpful? Give feedback.
-
@jacoboforero Your code has so many typos, you should check these; FundMe.staging.test.js
FundMe.test.js
Now make sure to use the same dependencies mentioned in the code repo, your project has dependencies conflicts and same hardhat require statements. Also make sure to change developmentChains spelling in deploy files. Now it is working perfectly! |
Beta Was this translation helpful? Give feedback.
-
I met the same issue.Make me crazy.I checked all the words.Can you help me have a look? const { deployments, ethers, getNamedAccounts } = require("hardhat")
const { assert } = require("chai")
// const { developmentChains } = require("../../helper.hardhat-config")
describe("FundMe", function () {
let fundMe
let deployer
let mockV3Aggregator
beforeEach(async () => {
deployer = (await getNamedAccounts()).deployer
await deployments.fixture()
fundMe = await ethers.getContract("FundMe", deployer)
mockV3Aggregator = await ethers.getContract(
"MockV3Aggregator",
deployer
)
})
describe("constructor", function () {
it("sets the aggregator addresses corretly", async () => {
const response = await fundMe.priceFeed()
assert.equal(response, mockV3Aggregator.address)
})
})
}) |
Beta Was this translation helpful? Give feedback.
@jacoboforero Your code has so many typos, you should check these;
FundMe.staging.test.js
developmentChains
correct it in this file as well as in helper file.developmentChains.includes
in the same filedescribe.skip
spelling mistakeFundMe.test.js
describe.skip
const { developmentChains } = require("../../helper-hardhat-config");
developmentChains.includes(network.name)
Now make sure to use the same dependencies mentioned in the code repo, your project has dependencies conflicts and same hardhat require statements.
A…