Main Vitest OOP decorator class Provides class-based test definition with Allure integration OOP test decorators for Vitest with Allure support

Remarks

Features:

  • Class-based test definition with decorators
  • Full Allure reporting integration
  • Scenario pattern for reusable test steps
  • Test lifecycle hooks (beforeAll, afterAll, before, after)
  • Test modifiers (skip, only, todo, timeout, repeats)
  • Suite options (mode, timeout, retries)
  • TypeScript support with full type safety

Example

import { suite, test, epic, severity, owner, tags } from '@biorate/vitest';
import { Severity } from 'allure-js-commons';
import 'reflect-metadata';

@suite('Authentication')
class AuthTest {
@epic('Security')
@feature('Login')
@story('User Authentication')
@severity(Severity.CRITICAL)
@owner('user-id-123')
@tags('auth', 'login', 'critical')
@test('should authenticate user')
async shouldAuthenticate() {
// test implementation
}
}

Example

import { suite, test, skip, only, todo, timeout, repeats } from '@biorate/vitest';

@suite('Edge Cases')
class EdgeCasesTest {
@skip()
@test('skip this test')
async skippedTest() {
// will be skipped
}

@only()
@test('run only this test')
async exclusiveTest() {
// only this test will run
}

@todo()
@test('todo test')
async todoTest() {
// marked as todo
}

@timeout(5000)
@test('test with timeout')
async timeoutTest() {
// will timeout after 5 seconds
}

@repeats(3, { mode: 'series' })
@test('flaky test')
async flakyTest() {
// will run 3 times in series
}
}

Example

import { Scenario, Step, Context } from '@biorate/vitest';

export class LoginScenario extends Scenario {
@Step('Open login page')
protected async openPage() {
await this.context.page.goto('/login');
}

@Step('Enter credentials')
protected async enterCredentials() {
await this.context.page.fill('#username', 'user');
await this.context.page.fill('#password', 'pass');
}
}

@suite('Login Flow')
class LoginTest {
@test('should login successfully')
async testLogin() {
await Context.run([LoginScenario], { page: this.page });
}
}

Example

import { suite, test } from '@biorate/vitest';

@suite('Database Tests')
class DatabaseTest {
protected static async beforeAll() {
// Setup before all tests
}

protected static async afterAll() {
// Cleanup after all tests
}

protected async before() {
// Setup before each test
}

protected async after() {
// Cleanup after each test
}

@test('should connect')
async shouldConnect() {
// test implementation
}
}

Constructors

Properties

allureSuite: any
description: any
epic: any
feature: any
id: any
issue: any
label: any
link: any
only: any

Only decorator factory

Example

@only()
owner: any
parentSuite: any
repeats: any

Repeats decorator factory

Example

@repeats(3)
severity: any
skip: any

Skip decorator factory

Example

@skip()
story: any
subSuite: any
suite: any

Suite decorator factory

Param: name

Suite name (optional, defaults to class name)

Param: options

Suite options (timeout, retries, mode)

Returns

Class decorator

Example

@suite('My Test Suite')
class MyTest {}

Example

@suite('Parallel Suite', { mode: 'parallel', timeout: 10000, retries: 2 })
class ParallelTest {}
tag: any
tags: any
test: any

Test decorator factory

Example

@test('should work')
timeout: any

Timeout decorator factory

Example

@timeout(5000)
todo: any

Todo decorator factory

Example

@todo()

Methods

  • Apply Allure metadata to the current test

    Parameters

    • allureMethods: AllureMetadata

      Allure methods and their arguments

    Returns Promise<void>

  • Create an Allure decorator factory

    Parameters

    • methodName: string

      Allure method name

    • append: boolean = false

      Whether to append multiple values

    Returns ((...args) => ((target, propertyKey, descriptor) => void))

      • (...args): ((target, propertyKey, descriptor) => void)
      • Parameters

        • Rest ...args: string[]

        Returns ((target, propertyKey, descriptor) => void)

          • (target, propertyKey, descriptor): void
          • Parameters

            • target: any
            • propertyKey: string
            • descriptor: PropertyDescriptor

            Returns void

  • Create an issue decorator with optional URL

    Returns ((name, url?) => ((target, propertyKey, descriptor) => void))

      • (name, url?): ((target, propertyKey, descriptor) => void)
      • Parameters

        • name: string
        • Optional url: string

        Returns ((target, propertyKey, descriptor) => void)

          • (target, propertyKey, descriptor): void
          • Parameters

            • target: any
            • propertyKey: string
            • descriptor: PropertyDescriptor

            Returns void

  • Create a link decorator with optional type parameter

    Returns ((url, name?, type?) => ((target, propertyKey, descriptor) => void))

      • (url, name?, type?): ((target, propertyKey, descriptor) => void)
      • Parameters

        • url: string
        • Optional name: string
        • Optional type: string

        Returns ((target, propertyKey, descriptor) => void)

          • (target, propertyKey, descriptor): void
          • Parameters

            • target: any
            • propertyKey: string
            • descriptor: PropertyDescriptor

            Returns void

  • Only decorator factory

    Returns ((target, propertyKey, descriptor) => void)

      • (target, propertyKey, descriptor): void
      • Parameters

        • target: any
        • propertyKey: string
        • descriptor: PropertyDescriptor

        Returns void

  • Register a single test method with Vitest

    Parameters

    • instance: any

      Class instance

    • name: string

      Method name

    • method: Function

      Method function

    • meta: TestMetadata

      Test metadata

    Returns void

  • Repeats decorator factory

    Parameters

    • count: number

      Number of repeats (must be positive)

    • Optional options: {
          mode?: "series" | "queue";
      }

      Repeat options

      • Optional mode?: "series" | "queue"

    Returns ((target, propertyKey, descriptor) => void)

      • (target, propertyKey, descriptor): void
      • Parameters

        • target: any
        • propertyKey: string
        • descriptor: PropertyDescriptor

        Returns void

  • Set Allure metadata method for a test

    Parameters

    • target: any

      Method or class target

    • method: string

      Allure method name (e.g., 'epic', 'severity')

    • args: any[]

      Method arguments

    • append: boolean = false

      Whether to append to existing metadata

    Returns void

  • Skip decorator factory

    Returns ((target, propertyKey, descriptor) => void)

      • (target, propertyKey, descriptor): void
      • Parameters

        • target: any
        • propertyKey: string
        • descriptor: PropertyDescriptor

        Returns void

  • Suite decorator factory

    Parameters

    • Optional name: string

      Suite name (optional, defaults to class name)

    • Optional options: SuiteOptions

      Suite options (timeout, retries, mode)

    Returns ((Class) => void)

      • (Class): void
      • Parameters

        • Class: (new () => any)
            • new (): any
            • Returns any

        Returns void

  • Test decorator factory

    Parameters

    • Optional name: string

      Test name (optional, defaults to method name)

    Returns ((target, propertyKey, descriptor) => void)

      • (target, propertyKey, descriptor): void
      • Parameters

        • target: any
        • propertyKey: string
        • descriptor: PropertyDescriptor

        Returns void

  • Timeout decorator factory

    Parameters

    • ms: number

      Timeout in milliseconds (must be positive)

    Returns ((target, propertyKey, descriptor) => void)

      • (target, propertyKey, descriptor): void
      • Parameters

        • target: any
        • propertyKey: string
        • descriptor: PropertyDescriptor

        Returns void

  • Todo decorator factory

    Returns ((target, propertyKey, descriptor) => void)

      • (target, propertyKey, descriptor): void
      • Parameters

        • target: any
        • propertyKey: string
        • descriptor: PropertyDescriptor

        Returns void