Lesson 7 yarn hardhat test not working(Stuck) #5903
-
So I am following the course and was building What I have tried:
Src I think you might need package.json: {
"devDependencies": {
"@chainlink/contracts": "^0.6.1",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
"@nomicfoundation/hardhat-ethers": "^3.0.0",
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
"@nomicfoundation/hardhat-toolbox": "^3.0.0",
"@nomicfoundation/hardhat-verify": "^1.0.0",
"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers",
"@typechain/ethers-v6": "^0.4.0",
"@typechain/hardhat": "^8.0.0",
"chai": "^4.2.0",
"ethers": "^6.6.4",
"hardhat": "^2.17.0",
"hardhat-deploy": "^0.11.34",
"hardhat-gas-reporter": "^1.0.8",
"mocha": "^10.2.0",
"solhint": "^3.4.1",
"solidity-coverage": "^0.8.0",
"typechain": "^8.1.0",
"undici": "^5.22.1"
},
"scripts": {
"compile": "yarn hardhat compile",
"deploy": "yarn hardhat deploy",
"test-all": "yarn mocha ./test/**/*.js",
"coverage": "yarn hardhat coverage",
"runNode": "yarn hardhat node",
"clean": "yarn hardhat clean"
},
"dependencies": {
"dotenv": "^16.3.1"
}
} hardhat.config.js: require("@nomicfoundation/hardhat-toolbox");
require("dotenv").config();
require("solidity-coverage");
require("hardhat-deploy");
const RPC_URL_SEPOLIA = process.env.RPC_URL_SEPOLIA || "";
const PRIV_KEY_SEPOLIA = process.env.PRIV_KEY_SEPOLIA;
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY;
const COINMARKETCAP_API_KEY = process.env.COINMARKETCAP_API_KEY;
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
defaultNetwork: "hardhat",
solidity: {
compilers: [
{ version: "0.8.19" },
{ version: "0.7.7" },
{ version: "0.6.6" },
],
},
networks: {
hardhat: {
blockConfirmations: 0,
},
sepolia: {
url: RPC_URL_SEPOLIA,
accounts: [PRIV_KEY_SEPOLIA],
chainId: 11155111,
blockConfirmations: 5,
},
localhost: {
url: "http://127.0.0.1:8545/",
chainId: 31337,
blockConfirmations: 0,
},
},
etherscan: {
apiKey: ETHERSCAN_API_KEY,
},
namedAccounts: {
deployer: {
default: 0,
31337: 0,
},
},
gasReporter: {
enabled: true,
outputFile: "./Test_Reports/Gas_Report.txt",
noColors: true,
currency: "USD",
coinmarketcap: COINMARKETCAP_API_KEY,
token: "ETH",
}
}; FundMe.test.js: const { assert } = require("chai");
const { deployments, ethers, getNamedAccounts } = require("hardhat");
describe("FundMe", function () {
console.log("Started test...");
let fundMe;
let deployer;
let MockV3Aggregator;
beforeEach(async () => {
deployer = (await getNamedAccounts()).deployer;
await deployments.fixture["all"];
fundMe = await ethers.getContract("FundMe", deployer);
MockV3Aggregator = await ethers.getContract(
"MockV3Aggregator",
deployer
);
});
describe("Constructor", () => {
it("Sets the aggregator addresses correctly", async () => {
const response = await fundMe.priceFeed();
assert.equal(response, MockV3Aggregator.address);
});
});
}); Update:
The execution is also not completed?
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Please share your repo |
Beta Was this translation helpful? Give feedback.
-
It works perfectly
|
Beta Was this translation helpful? Give feedback.
-
Dude can you help me too? I have been stuck on testing for a long time now |
Beta Was this translation helpful? Give feedback.
It works perfectly
yarn hardhat test