hardhat
hardhat copied to clipboard
Running A Single Test File, Hardhat Finds No Tests
Suppose I have some files in my project under the test folder
test/ - MyToken.test.js - MyHelperFunction.test.js - Foo.test.js
If I run npx hardhat test then it runs all the tests in all the files and everything works.
If I run npx hardhat test ./test/nonexistent.file.js then I can an error:
Error: Cannot find module '/Users/jim/Git-Projects/AppleTreeNFT-Smart-Contracts/packages/hardhat/test/nonexistent.file.js'
If I run npx hardhat test ./test/Foo.test.js then I get this output:
·------------------------|---------------------------|-------------|----------------------------·
| Solc version: 0.8.13 · Optimizer enabled: true · Runs: 200 · Block limit: 6718946 gas │
·························|···························|·············|·····························
| Methods │
··············|··········|·············|·············|·············|·············|···············
| Contract · Method · Min · Max · Avg · # calls · usd (avg) │
·-------------|----------|-------------|-------------|-------------|-------------|--------------·
0 passing (248ms)
When running any file I always get this "0 passing" message.
This is a bug because it should be running the tests in the file but it incorrectly runs nothing.
node v14.19.1
This issue is also being tracked on Linear.
We use Linear to manage our development process, but we keep the conversations on Github.
LINEAR-ID: 7c4aa311-0df3-4aa7-b6cc-d59df814676d
@JimLynchCodes this works for me. Can you tell me more about your setup? Are you on Windows? Which version of Hardhat are you using?
Also, just in case: can you try doing npx hardhat test test/Foo.test.js (that is, without the ./)?
Closing for lack of more information.