Error in Unit Testing: Chapter 7 #4625
Unanswered
Aditya-Vinit-Joshi
asked this question in
Q&A
Replies: 2 comments
-
check the name of fundme contract.
same as contract name FundMe. |
Beta Was this translation helpful? Give feedback.
0 replies
-
use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Fundme.Test.js
'''javascript
const {deployments,ethers, getNamedAccounts} = require("hardhat")
const {assert} = require("chai")
describe("FundMe",function(){
let fundMe
let deployer
let MockV3Aggregator
beforeEach(async function(){
//deploy fund me contract using hardhat-deploy
deployer = (await getNamedAccounts()).deployer
await deployments.fixture(["all"])
fundMe = await ethers.getContract("FundMe", deployer)
MockV3Aggregator = await ethers.getContract("MockV3Aggregator",deployer)
})
describe("contructor",async function(){
it("sets the aggregator addresses correctly",async function(){
const response = await fundMe.priceFeed()
assert.equal(response,MockV3Aggregator.address)
})
})
})
''''
00-deploy-mocks
'''javascript
const {network} = require("hardhat")
const {developmentChain, DECIMALS, INITIAL_ANSWER} = require("../helper-hardhat-config")
module.exports =
async (hre) =>{
const {deployments, getNamedAccounts} = hre
const {deploy,log} = deployments
module.exports.tags = ["all","mocks"]
'''
01-deploy-fundme.js
'''javascript
//import
const { network } = require("hardhat")
const { networkConfig, developmentChain } = require("../helper-hardhat-config")
module.exports =
async (hre) => {
const {getNamedAccounts, deployments} = hre
const {deploy, log} = deployments
'''
Error
'''error
aditya@DESKTOP-KOEELUN:~/etherium/hardhat/hardhat-fund-me-2/test$ yarn hardhat test --network localhost
yarn run v1.22.15
warning package.json: No license field
$ /home/aditya/etherium/hardhat/hardhat-fund-me-2/node_modules/.bin/hardhat test --network localhost
FundMe
contructor
Done in 3.09s.
'''
'''error
"before each" hook for "sets the aggregator addresses correctly":
Error: No Contract deployed with name FundMe
at Object.getContract (node_modules/@nomiclabs/hardhat-ethers/src/internal/helpers.ts:447:11)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at runNextTicks (node:internal/process/task_queues:65:3)
at listOnTimeout (node:internal/timers:528:9)
at processTimers (node:internal/timers:502:7)
at Context. (test/unit/Fundme.test.js:13:18)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
'''
I am trying to test locally.
Could anyone please help me out with this
Beta Was this translation helpful? Give feedback.
All reactions