Truffle: Running specific test file fails to find imports

Created on 6 Oct 2017  ·  13Comments  ·  Source: trufflesuite/truffle

  • [x] I've asked for help in the Truffle Gitter before filing this issue.

Issue

I’m trying to mock some contracts for my JS tests. My mock is location under a test/helpers/ directory; ie. test/helpers/MockToken.sol. MockToken extends from MyRealToken contract (located in the standard contracts/ directory).

The problem is that const MyToken = artifacts.require("./helpers/MockToken.sol”) fails with:

Error: Could not find artifacts for ./helpers/MockToken.sol from any sources

It fails ONLY when targeting a specific test file. It works fine if running all tests (untargeted).

Steps to Reproduce

With the configuration mentioned above, run:

node_modules/.bin/truffle test test/TokenBasic.js

Running the following will work:

node_modules/.bin/truffle test

Expected Behavior

The tests specified in the targeted test file to be run (ie. the MockToken contract would be loaded properly).

Actual Results

I receive this output:

Error: Could not find artifacts for ./helpers/MockToken.sol from any sources

Environment

  • Operating System: macOS
  • Truffle version: Truffle v3.4.11 (core: 3.4.11); Solidity v0.4.15 (solc-js)
  • Ethereum client: testrpc
  • node version: v8.4.0
  • npm version: 5.4.2
stale

Most helpful comment

Looks like the name of the contract & file has to be same otherwise it doesn't work.

more info

All 13 comments

Also having an error when testing a single file which doesn't happen when i run the full suite. Another error message tho,

This particular contract we re-deploy frequently from within the mocha suite. But from the logs it's hard to tell exactly what is happening.

  1) Contract: KittyCore Initial state "before all" hook: deployContract:
     Error: The contract code couldn't be stored, please check your gas amount.
      at Object.callback (node_modules/truffle/build/cli.bundled.js:218485:46)
      at node_modules/truffle/build/cli.bundled.js:34886:25
      at node_modules/truffle/build/cli.bundled.js:220423:9
      at node_modules/truffle/build/cli.bundled.js:204149:9
      at XMLHttpRequest.request.onreadystatechange (node_modules/truffle/build/cli.bundled.js:205574:13)
      at XMLHttpRequestEventTarget.dispatchEvent (node_modules/truffle/build/cli.bundled.js:73069:18)
      at XMLHttpRequest._setReadyState (node_modules/truffle/build/cli.bundled.js:73359:12)
      at XMLHttpRequest._onHttpResponseEnd (node_modules/truffle/build/cli.bundled.js:73514:12)
      at IncomingMessage.<anonymous> (node_modules/truffle/build/cli.bundled.js:73474:24)

Yes I have the same issue as the original poster

Same error:
truffle test test/CappedCrowdsale.js

Result

Error: Could not find artifacts for ./helpers/CappedCrowdsaleImpl.sol from any sources
    at Resolver.require (/my/path/zeppelin-solidity/node_modules/truffle/build/cli.bundled.js:50099:9)
    at TestResolver.require (/my/path/zeppelin-solidity/node_modules/truffle/build/cli.bundled.js:96057:30)
    at Object.require (/my/path/zeppelin-solidity/node_modules/truffle/build/cli.bundled.js:209900:32)
    at Object.<anonymous> (/my/path/zeppelin-solidity/test/CappedCrowdsale.js:14:35)
    at Module._compile (module.js:573:30)
    at loader (/my/path/EthicHub/zeppelin-solidity/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/my/path/zeppelin-solidity/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:507:32)
    at tryModuleLoad (module.js:470:12)
    at Function.Module._load (module.js:462:3)

Having the same issue

This is an issue with truffle v4 also. Invocation different but same result:

> truffle develop
truffle(develop)> test test/feeds.js

Error: Could not find artifacts for ./helpers/FeedsClient.sol from any sources
    at Resolver.require (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:63556:9)

Any updates on this?

I was using the pet-shop example, ran into same problem Could not find artifacts for ./TestAdoption.sol from any sources

Truffle v4.0.6 (core: 4.0.6)
pragma v0.4.17

Looks like the name of the contract & file has to be same otherwise it doesn't work.

more info

This worked for me! Thank you.

Thank you for raising this issue! It has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you would like to keep this issue open, please respond with information about the current state of this problem.

There has been no new activity on this issue since it was marked as stale 7 days ago, so it is being automatically closed. If you'd like help with this or a different problem, please open a new issue. Thanks!

just ran into this again with Truffle 0.5

Looks like the name of the contract & file has to be same otherwise it doesn't work.

more info

Looks like the name of the contract & file has to be same otherwise it doesn't work.

more info

I love You..It worked

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hickscorp picture hickscorp  ·  53Comments

dcnl1980 picture dcnl1980  ·  63Comments

JustinDrake picture JustinDrake  ·  29Comments

m888m picture m888m  ·  44Comments

akravin picture akravin  ·  53Comments