How to output tests results from truffle test command

Problem:

I need an output file so I can publish my test results as part of my build. Using the 'truffle test' command will run your test but no file is created for your CI systems.

Solution:

Update your Truffle config file with the following mocha reporter and reporter options:

mocha: {
    reporter: 'xunit',
    reporterOptions: {
      output: 'TEST-results.xml'
    }
}

Explanation:

Truffle uses Mocha under the hood to run your JavaScript based tests for your Smart Contracts. Using the Truffle config file, you can configure Mocha to output a file that can be used in your CI system to publish test results. 

Add comment

Loading