I have a Forge test file that I'm working on.
I have a bunch of tests running without any problem whatsoever.
BUT, VScode is marking my import of "forge-std/Test.sol" as incorrect, and there is a red line under it. See picture
The error message is : "Source "forge-std/Test.sol" not found: File import callback not supported"
What's very weird, is when I remove the import line, or remove my foundry 'Test' from
contract myContract is Test {
the tests do not work anymore.
I get this
error[7576]: DeclarationError: Undeclared identifier. Did you mean "assert"?
--> test/myContract.t.sol:35:9:
|
35 | assertEq(myContract.isPlayer(address(this), curCounter), true);
| ^^^^^^^^
What's happening here? Thanks in advance!
P.S. I added a remapping.txt file with "forge-std/=lib/forge-std/src/" but didn't help!
Best Answer
remappings.txt is used by VSCode to remap the imports (Forge might use the remappings declared in foundry.toml, remappings.txt or lookup in
./lib/
without the need to manually declare them, which is what's happening here). Havingforge-std/=lib/forge-std/src/
in remappings.txt will fix the VSCode integration (on a new line, without any quotation marks).To quickly generate it, based on the toml or auto-generated one, you can use
forge remappings > remappings.txt
PS: please note remappings.txt ;)