Running solidity-coverage gives the following error:
$npm run coverage
...
Writing artifacts to ./build/contracts
Launched testrpc on port 8555
Running: node --max-old-space-size=4096 ../node_modules/.bin/truffle test --network coverage ../tests/test0.js
(this can take a few seconds)...
Using network 'coverage'.
Error: ENOENT: no such file or directory, stat '/Users/solo/git/my-contract/coverageEnv/migrations'
Cleaning up...
Shutting down testrpc-sc (pid 5715)
Event trace could not be read.
Error: ENOENT: no such file or directory, open './allFiredEvents'
Exiting without generating coverage...
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-contract@0.0.1 coverage: `solidity-coverage`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-contract@0.0.1 coverage script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/solo/.npm/_logs/2018-10-07T17_16_27_017Z-debug.log
.solcover.js
module.exports = {
copyPackages: ['zeppelin-solidity'],
compileCommand: 'node --max-old-space-size=4096 ../node_modules/.bin/truffle compile --network coverage',
testCommand: 'node --max-old-space-size=4096 ../node_modules/.bin/truffle test --network coverage ../tests/test0.js',
port: '8555',
skipFiles: []
};
truffle-config:
…
module.exports = {
networks: {
...
coverage: {
host: 'localhost',
network_id: '*', // eslint-disable-line camelcase
port: 8555,
gas: 0xfffffffffff,
gasPrice: 0x01,
}
},
};
Running the testrpc and the test manually works just fine. But when running with solidity-coverage, for some reason it can't find the migrations
dir in coverageEnv
.
Any indication would be much appreciated. Thanks!
EDIT:
Although there might be a more elegant way to fix it, I managed to workaround this issue by copying the migrations scirpt as part of the testCommand: testCommand: 'cp -a ../migrations ../coverageEnv && node --max-old-space-size=4096 ../node_modules/.bin/truffle test --network coverage ../tests/test0.js',
Best Answer
Solidity-coverage creates a temporary directory based on your folder directory, I reccomend changing your test command to just be a path to your tests directory instead to a specific file.
Generally I use openzeppelin-solidity instead of zeppelin-solidity.
What is your file directory like?