contract.fromArtifact() Path on environment

I try to use the openzepplin/test-environnement module on my project, but when I use the contract.fromArtifact method I can’t reach my build folder with my contract in json. because of the architecture of my project, my build folder is not the root of the project.

does anyone know how to workaround ?

:computer: Environment

@openzeppelin/contract-loader : 0.5.0
@openzeppelin/test-environment : 0.1.1


The architecture of my project :

|–some stuff
|–test (api test)
|–build // the build is here in smart-contract folder
|–test (contract test)
|-test( contract + api test) // and it is here i need to found the build directory

:1234: Code to reproduce


 Error: Could not find compiled artifacts directory
  at loadArtifact (node_modules/@openzeppelin/contract-loader/lib/index.js:15:15)
  at Object.fromArtifact (node_modules/@openzeppelin/contract-loader/lib/index.js:50:18)
  at Object.getState (test/state.spec.js:18:31)
  at Context.<anonymous> (test/foo.spec.js:18:31)
  at processImmediate (internal/timers.js:456:21)
1 Like

Hi @vincent,

Welcome to the community :wave:
Thanks for posting your question in the forum.

I am not sure if this is currently possible (other than creating a soft link from build to smart-contract/build as a work around).
I will let you know if I find anything more.

1 Like

Hi @vincent,

I have created an Issue for this:

Were you able to use the work around of a soft link?

Hi @abcoathup ,

Thank you for creating this issue, it would be good to be able to add an optional parameter to specify the directory in which to search with the fromArtifact method.

To work around my problem I used the contract.fromAbi method by specifying my abi and my bytcode

1 Like

The latest version of Test Environment (v0.1.2) now supports the artifactsDir option, which replaces the default build/contracts path as the directory where .json artifacts are looked for.

In your project, that directory would be smart-contract/build/contracts. Enjoy!