-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Truffle test return TypeError: Cannot read property 'map' of undefined on specific case #4191
Comments
Currently Truffle and npm versions >7 don't play well together. What happens when you downgrade and use 6? Actually it is not surprising that |
Hi there, didn't tried with npm v6. If you run the dummy test describe in my post with only a it(); function inside. You will see in the console the console.log before the it() and then the error. |
Oh, I'm glad you found a workaround. I cannot duplicate your error however, can you provide more specific test steps with the minimal project to recreate this? You really shouldn't be creating artifact files directly as those are the files Truffle creates. I mean, you can do it if you know what you are doing but if they have the wrong format somehow they can cause errors like this. |
Had the same issue, at least the same title. The reason was corrupted file inside build/contracts directory cause by 3 party |
@vetal20600 could you tell us which 3rd party utility caused this corruption? That sounds like something we should reach out to them about. In the meantime, @FabienCoutant if you could get us those specific test steps, that'll help us understand what's going wrong. Thanks all! |
This utility packages called «truffle-deploy-registry»: https://www.npmjs.com/package/truffle-deploy-registry The problem is that I have some obsolete artifacts not used anymore. In this case the utiliy still inject network property leaving other properties blank @gnidan |
Hi! Sorry for the delay
here a test repo : https://github.com/FabienCoutant/Truffle-test-issue |
I´ve just had the exact problem. Thanks to @FabienCoutant workaround, it´s now possible to run the tests! Was found a cause and solution for this issue? Tks! |
So it looks like the problem is that you're supplying Truffle with a raw ABI JSON as opposed to a Truffle contract artifact, which is what Truffle expects. I think you need to wrap the ABI with something like this: https://github.com/FabienCoutant/Truffle-test-issue/commit/387ca878e72fc4a88d64cf3195022a5f872c9372 Sorry for the confusion. Please let me know if this helps! |
Closing this for issue maintenance. Let us know if there's still a problem! |
Hi, I am having same problem. Putting the ABI file in the test folder or its subfolder as mentioned by @FabienCoutant did not work for me. Also, the ABI is correctly wrapped as mentioned by @gnidan. ` Contract: PaymentContract` |
@olamideokunola Do you have a reproduction example we could inspect? Thanks! |
Steps to reproduce
UpdateFor now, I am using describe() function instead of contract() to run my tests |
Hm, so the error only occurs when the contracts build directory is outside of the project directory? Do I have that right? I'm not sure we support that case... @gnidan, can you comment on this? |
Hm, OK, @gnidan didn't respond here, but he says that putting the directory outside shouldn't be a problem, so I guess I'll take a look. |
OK, I can't reproduce this problem. Do you have a complete reproduction example we could check out on GitHub? Your example seems to be incompletely specified and it's possible that I filled in some of the gaps in the wrong way. (Also, you may want to check that you're using the latest version of Truffle.) Thanks! |
I also encountered this problem, and what fixed it for me was moving the build directory. In |
Issue
When I run
truffle test
ofnpx truffle test
I got the following error message:But! If I run
truffle compile
ortruffle migrate
I got no error.And even stranger if I install
solidity coverage
and runnpx truffle run coverage
, all my tests running as expected.After some days of investigation I found what causing this issue: I added into my
contracts_build_directory
others contract like USDC, etc. and this is what causing the error.Steps to Reproduce
Here the steps:
contracts_build_directory: path.join(__dirname, "client/src/contracts"),
In my cases I have my contract test files and a dummit test file (same code as above):
truffle test
ornpx truffle test
Expected Behavior
I expect no error or at least a clear error message.
Actual Results
truffe test
compile correctly the contract files and then throw an Error at the first it(). The error is not clear at allEnvironment
My co-worker on windows also have the issue.
truffle version
): v5.4.1node --version
): v15.11npm --version
): v7.19.1The text was updated successfully, but these errors were encountered: