5.0.0 • Published 3 months ago

@reportportal/agent-js-vitest v5.0.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 months ago

@reportportal/agent-js-vitest

Agent to integrate Vitest with ReportPortal.

Installation

Install the agent in your project:

npm install --save-dev @reportportal/agent-js-vitest

Configuration

1. Create vitest.config.ts file with ReportPortal configuration:

  import { defineConfig } from 'vitest/config';
  import RPReporter from '@reportportal/agent-js-vitest'; // or import { RPReporter } from '@reportportal/agent-js-vitest';

  const rpConfig = {
    apiKey: '00000000-0000-0000-0000-000000000000',
    endpoint: 'https://your.reportportal.server/api/v2',
    project: 'Your ReportPortal project name',
    launch: 'Your launch name',
    attributes: [
      {
        key: 'key',
        value: 'value',
      },
      {
        value: 'value',
      },
    ],
    description: 'Your launch description',
  };

  export default defineConfig({
    test: {
      reporters: ['default', new RPReporter(rpConfig)],
    },
  });

The full list of available options presented below.

OptionNecessityDefaultDescription
apiKeyRequiredUser's ReportPortal token from which you want to send requests. It can be found on the profile page of this user.
endpointRequiredURL of your server. For example 'https://server:8080/api/v1'.
launchRequiredName of launch at creation.
projectRequiredThe name of the project in which the launches will be created.
attributesOptional[]Launch attributes.
descriptionOptional''Launch description.
rerunOptionalfalseEnable rerun
rerunOfOptionalNot setUUID of launch you want to rerun. If not specified, ReportPortal will update the latest launch with the same name
modeOptional'DEFAULT'Results will be submitted to Launches page 'DEBUG' - Results will be submitted to Debug page.
debugOptionalfalseThis flag allows seeing the logs of the client-javascript. Useful for debugging.
launchIdOptionalNot setThe ID of an already existing launch. The launch must be in 'INPROGRESS' status while the tests are running. Please note that if this _ID is provided, the launch will not be finished at the end of the run and must be finished separately.
restClientConfigOptionalNot setThe object with agent property for configure http(s) client, may contain other client options eg. timeout. Visit client-javascript for more details.
launchUuidPrintOptionalfalseWhether to print the current launch UUID.
launchUuidPrintOutputOptional'STDOUT'Launch UUID printing output. Possible values: 'STDOUT', 'STDERR'. Works only if launchUuidPrint set to true.

The following options can be overridden using ENVIRONMENT variables:

OptionENV variable
launchIdRP_LAUNCH_ID

2. Add script to package.json file:

{
  "scripts": {
    "test": "vitest run"
  }
}

Reporting

When organizing tests, specify titles for describe blocks, as this is necessary to build the correct structure of reports.

Logging

You can use the following console native methods to report logs to the tests:

console.log();
console.info();
console.debug();
console.warn();
console.error();

console's log, info,dubug reports as info log.

console's error, warn reports as error log if message contains error mention, otherwise as warn log.