Lesson 7 : Unable to do unit testing in test rinkeby #381
Unanswered
HarishS-code
asked this question in
Q&A
Replies: 2 comments 1 reply
-
seems like you need to use beforeEach |
Beta Was this translation helpful? Give feedback.
1 reply
-
Hi! Could you please follow the guide here on asking questions in the course? https://www.youtube.com/watch?t=19846&v=gyMwXuJrbJQ&feature=youtu.be Using backticks helps format your code! |
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.
-
Hi guys , i am trying to understand why cannot we do unit testing in local network.
2)this my deploy contract it deploys perfectly to the testnet with network flag
const { getNamedAccounts, deployments, network } = require("hardhat");
const {
networkConfig,
developmentChains,
} = require("../helper-hardhat-config");
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments;
const { deployer } = await getNamedAccounts();
const chainId = network.config.chainId;
console.log(deployer);
console.log(chainId);
let ethUsdPriceFeedAddress;
ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"];
console.log(ethUsdPriceFeedAddress);
log("----------------------------------------------------");
log("Deploying FundMe and waiting for confirmations...");
const fundMe = await deploy("FundMe", {
from: deployer,
args: [ethUsdPriceFeedAddress],
log: true,
// we need to wait if on a live network so we can verify properly
waitConfirmations: network.config.blockConfirmations || 1,
});
log(
FundMe deployed at ${fundMe.address}
);log("----------------------------------------------------");
};
module.exports.tags = ["all", "fundme"];
const { assert, expect } = require("chai");
const { network, deployments, ethers } = require("hardhat");
const { developmentChains } = require("../../helper-hardhat-config");
describe("FundMe", async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments;
const { deployer } = await getNamedAccounts();
const chainId = network.config.chainId;
let minusd = 5;
let ethUsdPriceFeedAddress;
ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"];
console.log(ethUsdPriceFeedAddress);
log("----------------------------------------------------");
log("Deploying FundMe and waiting for confirmations...");
const fundMe = await deploy("FundMe", {
from: deployer,
args: [ethUsdPriceFeedAddress],
log: true,
waitConfirmations: network.config.blockConfirmations || 1,
});
it("should check minimum usd", async () => {
const min = await fundMe.MINIMUM_USD();
assert.equal(min.toString(), "5");
});
});
When i try to run
yarn hardhat test --network rinkeby
i get empty coverage results
Beta Was this translation helpful? Give feedback.
All reactions