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 🙏

© 2024 – Pkg Stats / Ryan Hefner

relax-steps-allure

v0.1.1

Published

Utils for test stepping, logging and reporting. See more at https://github.com/qx57/relax-steps-allure

Downloads

14

Readme

relax-steps-allure

Create your autotests more easily! Step tools with simple allure reporting.

You must use mocha test starter if you want use this package with mocha-multi-reporter

Requirements

  • node.js ^17.9.0
  • ts-node ^9.1.1
  • mocha ^8.2.1
  • mocha-multi-reporter ^1.5.1

Dependencies

  • @types/node ^17.0.41

Installation

> npm i relax-steps-allure

Getting started

  1. Init started reporting configuration:
> npx relax-steps-allure setinit

for creation .mocharc.json and reporterConfig.json files (needed for correct package work). If you have this files - just update it (you don't need install anymore else):

  • .mocharc.json:
{
    ...
    "require": ["ts-node/register"],
    "reporter": "mocha-multi-reporters",
    "reporter-option": "configFile=reporterConfig.json"
    ...
}
  • reporterConfig.json (default variant):
{
    "reporterEnabled": "allure-mocha, list",
    "allureMochaReporterOptions": {
        "resultsDir": "./allure-results"
    }
}
  1. Include step tools into your test:
import { step } from 'relax-steps-allure';

or

const step = require('relax-steps-allure').step;
  1. Use steps in tests:
it('My test', async () => {
    await step('Step', async () => {
        // Some code of your case step
    });
    await step('One more step', async () => {
        // ...
    });
});
  1. Enjoy! Your report is in allure-results =)

Additional usage

Nope test

if you can prepare your automation test but must commit it immediately - use nit method:

nit('My test', async () => {
    await step('First step', async () => {});
    await step('Second step', async () => {});
    // ...
});

and your code never starts when suite is runned. Also you can create test cases for future automation just in suite.

Error's await

When you await some error or exception in your test - you have two ways catch it without test falling:

  • You can catch error throug its type:
import { step, stepIgnoreError } from 'relax-steps-allure';

it('Test with some error', async () => {
    // ...
    await stepIgnoreError('Step with error', TypeError, async () => {
        throw new TypeError('Some error happens');
    });
});
  • Or you can use exception catching by its message:
import { step, stepIgnoreErrorByMessage } from 'relax-steps-allure';

it('Another test with some error', async () => {
    // ...
    await stepIgnoreErrorByMessage('Another step with error', 'Shit happens', async () => {
        throw new Error('Shit happens');
    });
});

Error catching

If you don't know what error will happens, you can use stepCatchError. This method returns boolean, true if error happened or false if your step runned without errors:

import { step, stepCatchError } from 'relax-steps-allure';

it('Test with various error', async () => {
    // ...
    let isError = await stepCatchError('Step with various error', async () => {
        throw new Error('Shit happens');
    });

    await step('Check that error happened', async () => {
        assert(isError);
    });
});

API logging

When you testing API endpoints, you can use request/response attachment which attached with step each time when you send request in it - just use annotation @AllureApiAttaches in API controller:

class ApiController {

    @AllureApiAttaches('MY API REQUEST')
    async apiRequest(
        headers: any,
        body: any
    ) {
        return api.request(headers, body).response;
    }
}

Contributors

qx57