So I am using truffle. Following from Creating a form in IPFS for users to enter data [check the code in answer], doing some changes:

Contract name - IpfsContract.sol test.js uses the following JSON Structure within the test():

const data = JSON.stringify({
        name: "Rahul Kothari",
        age: "21",  // maybe "21"?
        sex: "male"

My 1_initial_migration.js and truffle-config.js files work fine!

Using truffle develop, on CMD I run truffle compile truffle migrate. Works perfectly! I then run truffle test and it displays: 0 passing (1ms) in green. No other output although, my test.js used console.log!

Any help will be appreciated! Thanks!

1 Answer 1


There are no files in test folder. As per truffle when you run test with out options it will look into test folder inside your project. Make sure you have test.js inside test. If there are no files then it will execute 0 test case's so that's reason it showing 0 test cases passed.

  • But I do have a test.js file in my test folder Commented Feb 15, 2018 at 11:31
  • @RahulKothari Can you paste your test log. Commented Feb 15, 2018 at 11:37
  • const IPFS = require('ipfs') const node = new IPFS() const IpfsContract = artifacts.require("IpfsContract") async function test() { const data = JSON.stringify({ name: "Rahul Kothari", age: "21", // maybe 21? sex: "male" }) const ipfsHash = await node.add(data) const instance = await IpfsContract.deployed() await instance.setHash.sendTransaction(ipfsHash) let returnedHash = await instance.ipfsHash.call() console.log(ipfsHash) console.log(returnedHash) console.log(JSON.parse(await node.cat(returnedHash))) } test() Commented Feb 15, 2018 at 12:26
  • Sorry that the thing looks a bit messy, but the comments here cant be long Commented Feb 15, 2018 at 12:27
  • 1
    But await only works within async functions right? Also, it still doesnt work Commented Feb 15, 2018 at 12:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.