The Tesults web app is designed for desktop browsers. Sign up and configure your project on a laptop or desktop. Use the iOS app or Android app to view results on the go.

Add logs to test reporting with Tesults

Save test logs for test reporting purposes with Tesults

blog-title-image

Logging output from a test case as it runs is useful to get a detailed understanding of what went on during the test later when viewing a report.

With Tesults it’s easy to save test logs for each test case. If you are using one of the Tesults reporters or plugins for a popular testing framework such as JUnit, TestNG, pytest, Robot Framework, Mocha, Jest, NUnit, RSpec, Cypress and TestCafe then you simply need to save your log to the appropriate temporary path while your tests run and the log will automatically upload to Tesults and be available for viewing in the test case detail view.

If you are using a Tesults API library, such as for Java, C#, Python, Ruby, JavaScript (Node.js), Kotlin or Go then you just need to supply the paths to the logs you write to for each test case during the test run.

Let’s get into the details for both options.

Using a Tesults reporter or plugin

All Tesults reporters can be passed a files directory, this is where all of your test files are expected to be located, at least temporarily during the test run. Then all reporters expect the directory structure to consist of the test suite name, test case name, and then this directory should containing all of the files for the test case:

/temp/{suite name}/{test case name}/file1
/temp/{suite name}/{test case name}/file2

Using the Mocha Tesults Reporter as an example, you can pass in the tesults-files arg to the reporter with the value set to the directory where all of test files will be stored during the test run (these can be deleted following the test run):

package.json
{
  "name": "Example",
  "version": "1.0.0",
  "description": "Example",
  "main": "index.js",
  "scripts": {
    "test": "mocha * --reporter mocha-tesults-reporter -- tesults-target=token tesults-files=/full-path/temp"
  },
  "author": "Tesults",
  "license": "MIT",
  "dependencies": {
    "mocha": "^8.0.1",
    "mocha-tesults-reporter": "^1.1.1"
  }
}

Then in your tests you must write to the log file saved at files/{suite name}/{test case name} e.g.

tests.js
const assert = require('assert');
const fs = require('fs');
const path = require('path');

describe('Test Suite A', function () {
    const temp = "/full-path/temp";
    it ('Test 1', function () {
        const testLogPath = path.join(temp, 'Test Suite A', 'Test 1', 'test.log');
        fs.writeFileSync(testLogPath, "write something to the log");
    });
    it ('Test 2', function () {
        assert.fail('Test failed due to assert fail in line 9');
    });
    it ('Test 3', function () {
        // this test passes
    }); 
});

That’s all it takes to have the log file saved to Tesults. When you view test results on Tesults and open test case details you will be able to see that the log is available for viewing. You can add other files, such as screenshots in the same way.

s1
Using a Tesults API Library

In the case of the API libraries you can write to a log that you can save anywhere and then supply the path to the log file in the files property for a test case.

Using JavaScript as an example:

const tesults = require('tesults');

const data = {
    target: 'token',
    results: {
      cases: [
      {
        name: 'Test 1',
        desc: 'Test 1 description.',
        suite: 'Test Suite A',
        result: 'pass',
        files: ['/full-path/temp/Test Suite A/Test 1/test.log', '/full-path/temp/Test Suite A/Test 1/screenshot.png']
      }
      ]
    }
  }

When you view test results on Tesults and open a test case detail you will be able to see that the log is available for viewing. You can add other files, such as screenshots in the same way.

s2

For more information view the documentation for specific Tesults API Libraries and reporters and plugins:

EXP (a test framework by Tesults that makes logging even easier)
JUnit 5
JUnit 4
TestNG
pytest
Robot Framework
NUnit
MSTest
RSpec
Mocha
Jest
Protractor
Cypress
TestCafe

Java
C#
Python
Ruby
JavaScript / Node.js
Kotlin
Go (Golang)


- Tesults Team

Test automation reporting and failure intelligence

Consolidated test reporting for engineering teams. Store, track, and understand test results across every run and system.

Latest Posts

Why Cypress Tests Pass Locally but Fail in CI
Why Cypress Tests Pass Locally but Fail in CI
The environment differences that cause Cypress failures in CI, and how to tell a real bug from an environment flake
How to Track Test Pass Rate Over Time
How to Track Test Pass Rate Over Time
Why a single run cannot tell you if your test suite is getting healthier or worse, and how to track pass rate as a trend across runs so you can see the direction
How to Report WebdriverIO Test Results to a Dashboard
How to Report WebdriverIO Test Results to a Dashboard
Send WebdriverIO results somewhere durable and team-visible using the Tesults service, with the wdio.conf.js setup, enhanced reporting, and parallel run consolidation
How to Report Cypress Test Results to a Dashboard
How to Report Cypress Test Results to a Dashboard
Send Cypress results somewhere durable and team-visible using the Cypress Module API, with screenshots and videos attached and runs consolidated across CI
Why Playwright Tests Pass Locally but Fail in CI
Why Playwright Tests Pass Locally but Fail in CI
The real reasons Playwright tests go green on your machine and red in CI, how to debug each one, and how to tell a genuine failure from an environment flake
How to Detect and Handle Flaky Tests
How to Detect and Handle Flaky Tests
What makes a test flaky, how to detect flaky tests automatically instead of by memory, and how to handle them without disabling coverage
How to Report Vitest Test Results to a Dashboard
How to Report Vitest Test Results to a Dashboard
Send Vitest results somewhere durable and team-visible, with the setup details specific to Vitest, so multiple test jobs consolidate into one history you can act on
How to Report Go Test Results to a Dashboard
How to Report Go Test Results to a Dashboard
Go has no reporter plugin, so reporting go test results means parsing go test -json and uploading the cases yourself. Here is the whole pattern.
How to Report Jest Test Results to a Dashboard
How to Report Jest Test Results to a Dashboard
How to send Jest results somewhere they are kept, viewable by the team, and comparable across runs, without giving up the default reporter
How to View Playwright Test Results in CI
How to View Playwright Test Results in CI
How to get Playwright results out of the CI console and into a durable dashboard, including parallel shards, screenshots, and retained history
What Is a Test Results Dashboard and When Do You Need One
What Is a Test Results Dashboard and When Do You Need One
What a test results dashboard actually does, how it differs from your CI logs and your test framework report, and the point at which a team starts needing one
Diagnosing CI Failures Automatically With an AI Failure Diagnosis API
Diagnosing CI Failures Automatically With an AI Failure Diagnosis API
How to turn a red build into a root cause, a regression list, and a deploy gate without a human reading the logs