npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

k6-report-portal

v1.1.0

Published

K6 Report Portal integration with test decorators

Readme

k6-report-portal

A library for k6 that provides integration with Report Portal and test decorators.

Overview

This library allows you to:

  • Integrate k6 tests with Report Portal for result visualization
  • Use decorators to organize tests into suites
  • Configure test metadata (priority, features, service, etc.)
  • Manage test execution with detailed logging

Usage

How to use this library in your project:

npm init
npm install --save-dev @babel/core @babel/cli @babel/preset-env
npm install --save-dev @babel/plugin-proposal-decorators @babel/plugin-proposal-class-properties

Client side project structure

├── src/
│   └── config.js     # Load configuration
├── test/
│   └── exampleTest.js  # Test files using decorators
├── .babelrc
├── main.js
└── package.json

Setup

1. Configure Babel

Create a .babelrc file in your project root:

{
  "presets": ["@babel/preset-env"],
  "plugins": [
    ["@babel/plugin-proposal-decorators", { "legacy": true }],
    ["@babel/plugin-proposal-class-properties"]
  ]
}

2. Environment Configuration

Create a .env file with the following variables:

# Report Portal Configuration
RP_ENDPOINT=http://localhost:8080
RP_TOKEN=your_token_here
RP_PROJECT=PLATFORM-FUNCTIONAL-TESTS
RP_LAUNCH=Access Control API Tests
RP_DESCRIPTION=Access Control API Tests
RP_MODE=DEFAULT
RP_COMPONENT=Platform

# Comma separated list of test suites to run
ENABLED_SUITES=exampleTest

# K6 Options
VUS=1
ITERATIONS=1
MAX_DURATION=5m

3. Configuration Module

Create a config.js file in the src directory:

export function loadConfig() {
    return {
        baseURL: __ENV.BASE_URL,
        token: __ENV.AUTH_TOKEN,
        reporterConfig: {
            endpoint: __ENV.RP_ENDPOINT,
            token: __ENV.RP_TOKEN,
            project: __ENV.RP_PROJECT,
            launch: __ENV.RP_LAUNCH,
            description: __ENV.RP_DESCRIPTION,
            mode: __ENV.RP_MODE,
            component: __ENV.RP_COMPONENT
        },
        enabledSuites: (__ENV.ENABLED_SUITES || '').split(',')
    };
}

Writing Tests

Create test files in the test directory. Here's an example:

import {Suite, Test, Setup, Teardown} from 'https://cdn.jsdelivr.net/npm/[email protected]/lib/index.min.js';

@Suite({
    name: 'Example Suite',
    description: 'Test suite description'
})
class ExampleTests {
    @Setup()
    async setup({testId, logger, baseURL}) {
        return {}
    }
    
    @Test({
        name: 'Example Test',
        description: 'Test description',
        priority: 'P1',
        features: ['policies'],
        service: 'AUTHZ'
    })
    async exampleTest(data, {testId, logger}) {
        logger.info(testId, "Test execution");
    }

    @Teardown()
    async setup(data, {testId, logger, baseURL}) {}
}

export default new ExampleTests();

Test Entry Point

Create a main.js file in your project root:

import {runSuites, createReporter} from 'https://cdn.jsdelivr.net/npm/[email protected]/lib/index.min.js';
import {loadConfig} from './src/config.js';
// !IMPORTANT: Import test suites from the build directory
import exampleTest from './build/test/exampleTest.js';

export function setup() {
    return loadConfig();
}

export default async function (config) {
    let reporter = createReporter(config.reporterConfig);
    let logger = reporter.start();

    if (!logger) {
        throw new Error('Failed to initialize reporter');
    }

    try {
        await runSuites({
            ...config,
            logger,
            testSuites: {
                // !IMPORTANT: Add imported test suites to the testSuites object
                'exampleTest': exampleTest
            }
        });
        reporter.finish();
    } catch (error) {
        reporter.finish('FAILED');
        throw error;
    }
}

Running Tests

Execute your tests with:

npm run test:local

Available Decorators

  • @Suite: Defines a test suite with metadata
  • @Test: Defines a test case with metadata
  • @Setup: Defines setup code to run before tests
  • @Teardown: Defines cleanup code to run after tests

Report Portal Integration

This library automatically:

  • Creates a launch in Report Portal
  • Creates test suites and test cases
  • Reports test results and logs
  • Handles test lifecycle events