Socket
Socket
Sign inDemoInstall

@saucelabs/sauce-json-reporter

Package Overview
Dependencies
Maintainers
21
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@saucelabs/sauce-json-reporter

A javascript library for creating Sauce Labs JSON test results.


Version published
Weekly downloads
7.7K
decreased by-27.41%
Maintainers
21
Weekly downloads
 
Created
Source

sauce-json-reporter-js

A javascript library for creating Sauce Labs JSON test results.

A JSON schema describing the report is also available.

Examples

const {TestRun, Status} = require('@saucelabs/sauce-json-reporter');

let r = new TestRun()
r.attach({name: 'screenshot.png', path:'./screenshot.png'})
const s1 = r.withSuite('somegroup')
const s2 = s1.withSuite('somefile.test.js')
s1.attach({name: 'screenshot1.png', path: './screenshot1.png'})
s2.withTest('yay', {
  status: Status.Passed,
  duration: 123,
  attachments: [
    {name: 'video.mp4', path: './video.mp4'},
    {name: 'screenshot2.png', path: './screenshot2.png'}
  ],
})
s2.withTest('nay', {
  status: Status.Failed,
  output: 'test failed',
  duration: 123,
  attachments: [
    {name: 'video.mp4', path: './video.mp4'},
  ]
})
s2.withTest('oops', {
  status: Status.Skipped,
  output: 'test skipped',
  duration: 123,
})

r.metadata = {
  'id': '123'
}

r.stringify() // returns a JSON string representing the entire test run
// or
r.toFile('my_json_report.json') // writes the JSON to a file instead
// or
r.toJUnitFile('my_junit_report.xml') // converts and writes the result to a JUnit file

The resulting JSON of the above example is:

{
  "status": "failed",
  "attachments": [
    {
      "name": "screenshot.png",
      "path": "./screenshot.png"
    }
  ],
  "suites": [
    {
      "name": "somegroup",
      "status": "failed",
      "metadata": {},
      "suites": [
        {
          "name": "somefile.test.js",
          "status": "failed",
          "metadata": {},
          "suites": [],
          "attachments": [],
          "tests": [
            {
              "name": "yay",
              "status": "passed",
              "duration": 123,
              "startTime": "2023-06-19T18:26:06.227Z",
              "attachments": [
                {
                  "name": "video.mp4",
                  "path": "./video.mp4"
                },
                {
                  "name": "screenshot2.png",
                  "path": "./screenshot2.png"
                }
              ],
              "metadata": {}
            },
            {
              "name": "nay",
              "status": "failed",
              "duration": 123,
              "output": "test failed",
              "startTime": "2023-06-19T18:26:06.227Z",
              "attachments": [
                {
                  "name": "video.mp4",
                  "path": "./video.mp4"
                }
              ],
              "metadata": {}
            },
            {
              "name": "oops",
              "status": "skipped",
              "duration": 123,
              "output": "test skipped",
              "startTime": "2023-06-19T18:26:06.227Z",
              "attachments": [],
              "metadata": {}
            }
          ]
        }
      ],
      "attachments": [
        {
          "name": "screenshot1.png",
          "path": "./screenshot1.png"
        }
      ],
      "tests": []
    }
  ],
  "metadata": {
    "id": "123"
  }
}

The resulting JUnit file of the above example is:

<testsuites status="failed" tests="3" failures="1" skipped="1" time="0.369">
  <testsuite name="somegroup" status="failed" tests="0" failures="0" skipped="0" time="0">
    <properties>
      <property name="attachment" value="screenshot1.png">./screenshot1.png</property>
    </properties>
  </testsuite>
  <testsuite name="somefile.test.js" status="failed" tests="3" failures="1" skipped="1" time="0.369">
    <testcase name="yay" status="passed" time="0.123" timestamp="2023-06-20T21:32:07.467Z">
      <properties>
        <property name="attachment" value="video.mp4">./video.mp4</property>
        <property name="attachment" value="screenshot2.png">./screenshot2.png</property>
      </properties>
    </testcase>
    <testcase name="nay" status="failed" time="0.123" timestamp="2023-06-20T21:32:07.467Z">
      <properties>
        <property name="attachment" value="video.mp4">./video.mp4</property>
      </properties>
      <failure>
        <![CDATA[test failed]]>
      </failure>
    </testcase>
    <testcase name="oops" status="skipped" time="0.123" timestamp="2023-06-20T21:32:07.467Z">
      <skipped>
        <![CDATA[test skipped]]>
      </skipped>
    </testcase>
  </testsuite>
  <properties>
    <property name="attachment" value="screenshot.png">./screenshot.png</property>
    <property name="id" value="123"/>
  </properties>
</testsuites>

FAQs

Package last updated on 29 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc