trufflesuite / truffle

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
14.02k stars 2.32k forks source link

Feature request: Support saving Mocha test output to a file #5229

Open thanghv97 opened 2 years ago

thanghv97 commented 2 years ago

Issue

Config output file mocha not working in Truffle Config I followed this post (https://trufflesuite.com/guides/ethereum-devops-truffle-testrpc-vsts/#prepare-trufflejs) to set config mocha that log output testing to file. However, this post is archived. I tried it but it not working, it still logs to stdout, and no file is generated. How i should set config mocha to log output testing to file? I need the file to generate the report then.

Steps to Reproduce

Setting truffle-config.js

   mocha: {
     reporter: “json”,
     reporterOptions: {
       mochaFile: `junitresults.json`
     }
   }

Expected Behavior

The result of testing is logged to file junitresults.json

Actual Results

The log format is changed to JSON format. However, The result of testing is still logged to stdout

  {
    "stats": {
          .....
    },
    "tests": [

    ],
    "pending": [],
    "failures": [],
    "passes": [
             ............
    ]
  }

Environment

eggplantzzz commented 2 years ago

Ah yes that looks like a very old tutorial. Currently I don't believe Truffle supports this but I will leave this issue here as a feature request. Thanks for submitting this issue!