Replies: 2 comments
-
Did you find the solution for this? |
Beta Was this translation helpful? Give feedback.
-
Verify that developmentChains in helper-hardhat-config.js does not include sepolia. For example: const developmentChains = ["hardhat", "localhost"]; 2- The staging test uses a ternary operator to conditionally skip the describe block if the network is a development chain. Ensure that the logic is correct: developmentChains.includes(network.name)
? describe.skip
: describe("FundMe", async () => {
// Test logic
});
console.log("Network name:", network.name);
console.log("Development chains:", developmentChains);
module.exports = {
networks: {
sepolia: {
url: "https://sepolia.infura.io/v3/YOUR_INFURA_PROJECT_ID",
accounts: [process.env.PRIVATE_KEY],
},
},
};
npx hardhat test test/staging/FundMe.staging.test.js --network sepolia
const { deployments, ethers } = require("hardhat");
const { developmentChains } = require("../../helper-hardhat-config");
const { assert } = require("chai");
console.log("Network name:", network.name);
console.log("Development chains:", developmentChains);
developmentChains.includes(network.name)
? describe.skip
: describe("FundMe", async () => {
let FundMe;
let signer;
let sendValue = ethers.formatEther("0.01");
beforeEach(async () => {
const accounts = await ethers.getSigners();
signer = accounts[0];
const FundMeDeployment = await deployments.get("FundMe");
FundMe = await ethers.getContractAt(
FundMeDeployment.abi,
FundMeDeployment.address,
signer,
);
});
it("allows people to fund and withdraw", async () => {
await FundMe.fund({ value: sendValue });
await FundMe.withdraw();
const endingBalance = await ethers.provider.getBalance(
FundMe.getAddress(),
);
assert.equal(endingBalance.toString(), "0");
});
}); |
Beta Was this translation helpful? Give feedback.
-
It's strange, I've been searching for the discussion for a long time and haven't had the same issue.
npx hardhat test --network sepolia
staging test 0 passing, no any error, I don't understand. test/staging/FundMe.staging.test.js!
before developmentChains, it should run describe when I donpx hardhat test --network sepolia
. I tried log something beforebeforeEach
, but there is nothing in the console.Why ??????
FundMe.staging.test.js
FundMe.test.js
Beta Was this translation helpful? Give feedback.
All reactions