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

@frinzekt/cypress-allure-plugin

v0.0.1-development

Published

allure reporting plugin for cypress modified for video. Originally by @shelex

Downloads

49

Readme

cypress-allure-plugin

Plugin for integrating allure reporter in Cypress with support of Allure API.

Build Downloads semantic-release
version License

Installation

Setup

  • Connect plugin in cypress/plugins/index.js in order to add Allure writer task:

    • as only plugin:
    const allureWriter = require('@shelex/cypress-allure-plugin/writer');
    
    module.exports = (on, config) => {
        allureWriter(on, config);
        return config;
    };
    • if you have webpack or other preprocessors please set allure writer last:
    module.exports = (on, config) => {
        on('file:preprocessor', webpackPreprocessor);
        allureWriter(on, config);
        return config;
    };
  • Register commands in cypress/support/index.js file:

    • with import:
    import '@shelex/cypress-allure-plugin';
    • with require:
    require('@shelex/cypress-allure-plugin');
  • for IntelliSense (autocompletion) support in your IDE add on top of your cypress/plugins/index.js file:

/// <reference types="@shelex/cypress-allure-plugin" />
  • for typescript support, update your tsconfig.json:
"include": [
   "../node_modules/@shelex/cypress-allure-plugin/reporter",
   "../node_modules/cypress"
 ]

Configuration

Plugin is customizable via Cypress environment variables:

| env variable name | description | default | | :------------------------------------- | :------------------------------------------------------------------- | :--------------- | | allure | enable Allure plugin | false | | allureResultsPath | customize path to allure results folder | allure-results | | tmsPrefix | prefix for links from allure API in tests to test management system | | | `issuePrefix` | prefix for links from allure API in tests to bug tracking system | | | allureLogCypress | log cypress chainer (commands) and display them as steps in report | true | | allureOmitPreviousAttemptScreenshots | omit screenshots attached in previous attempts when retries are used | false |

This options could be passed:

  • via cypress.json

    {
        "env": {
            "allureResultsPath": "someFolder/results",
            "tmsPrefix": "https://url-to-bug-tracking-system/task-",
            "issuePrefix": "https://url-to-tms/tests/caseId-"
            // usage:  cy.allure().issue('blockerIssue', 'AST-111')
            // result: https://url-to-bug-tracking-system/task-AST-111
        }
    }
  • via command line:

    yarn cypress run --env allure=true,allureResultsPath=someFolder/results
  • via Cypress environment variables:

    Cypress.env('issuePrefix', 'url_to_bug_tracker');

Execution

  • be sure your docker or local browser versions are next: Chrome 71+, Edge 79+. Firefox 65+

  • plugin might not be applied to older Cypress versions, 4+ is recommended

  • to enable Allure results writing just pass environment variable allure=true, example:

npx cypress run --env allure=true
  • if allure is enabled, you can check gathered data, in cypress window with Chrome Developer tools console:
Cypress.Allure.reporter.runtime.writer;

Examples

See cypress-allure-plugin-example project, which is already configured to use this plugin, hosting report as github page and run by github action. It has configuration for basic allure history saving (just having numbers and statuses in trends and history).
For complete history (allure can display 20 build results ) with links to older reports and links to CI builds check cypress-allure-historical-example with basic and straightforward idea how to achieve it.

There are also existing solutions that may help you prepare your report infrastructure:

  • Allure Server - self-hosted portal with your reports
  • allure-reports-portal - another portal which allows to gather reports for multiple projects in single ui
  • Github Action - report generation + better implementation for historic reports described above
  • Allure TestOps - Allure portal for those who want more than report

How to open report

Assuming allure is already installed:

  • serve report based on current "allure-results" folder: allure serve
  • generate new report based on current "allure-results" folder: allure generate
  • open generated report from "allure-report" folder: allure open

API

There are three options of using allure api inside tests:

  1. Using interface from Cypress.Allure.reporter.getInterface() - synchronous
const allure = Cypress.Allure.reporter.getInterface();
allure.feature('This is our feature');
allure.epic('This is epic');
allure.issue('google', 'https://google.com');
  1. Using Cypress custom commands, always starting from cy.allure() - chainer
cy.allure()
    .feature('This is feature')
    .epic('This is epic')
    .issue('google', 'https://google.com')
    .parameter('name', 'value')
    .tag('this is nice tag');
  1. Using Cypress-cucumber-preprocessor with cucumber tags:
@subSuite("someSubSuite")
@feature("nice")
@epic("thisisepic")
@story("cool")
@severity("critical")
@owner("IAMOwner")
@issue("jira","PJD:1234")
@someOtherTagsWillBeAddedAlso
Scenario: Here is scenario
...

Allure API available:

  • epic(epic: string)
  • feature(feature: string)
  • story(story: string)
  • suite(name: string)
  • label(name: LabelName, value: string)
  • parameter(name: string, value: string)
  • testParameter(name: string, value: string)
  • link(url: string, name?: string, type?: LinkType)
  • issue(name: string, url: string)
  • tms(name: string, url: string)
  • description(markdown: string)
  • testDescription(markdown: string)
  • descriptionHtml(html: string)
  • testDescriptionHtml(html: string)
  • owner(owner: string)
  • severity(severity: Severity)
  • tag(tag: string)
  • attachment(name: string, content: Buffer | string, type: ContentType)
  • testAttachment(name: string, content: Buffer | string, type: ContentType)
  • fileAttachment(name: string, path: string, type: ContentType)
  • startStep(name: string)
  • endStep()
  • step(name: string, isParent: boolean)

VS Code for cypress + cucumber

In case you are using VS Code and Cypress Helper extension, it has configuration for allure cucumber tags autocompletion available:

"cypressHelper.cucumberTagsAutocomplete": {
        "enable": true,
        "allurePlugin": true,
        "tags": ["focus", "someOtherTag"]
    }

Screenshots and Videos

Screenshots are attached automatically, for other type of content feel free to use testAttachment (for current test), attachment (for current executable), fileAttachment (for existing file).
Videos are attached for failed tests only from path specified in cypress config videosFolder and in case you have not passed video=false to Cypress configuration. Please take into account, that in case spec files have same name, cypress is trying to create subfolders in videos folder, and it is not handled from plugin unfortunately, so video may not have correct path in such edge case.

Cypress commands

Commands are producing allure steps automatically based on cypress events and are trying to represent how code and custom commands are executed with nested structure.
Moreover, steps functionality could be expanded with:

  • cy.allure().step('name') - will create step "name" for current test. This step will be finished when next step is created or test is finished.
  • cy.allure().step('name', false) - will create step "name" for current parent step (like previous one, without passing false as second argument) or current hook/test. Will be finished when next step is created or test finished.
  • cy.allure().startStep('name') - will create step "name" for current cypress command step / current step / current parent step / current hook or test. Is automatically finished on fail event or test end, but I would recommend to explicitly mention cy.allure().endStep() which will finish last created step.

Testing

  • yarn test:prepare:basic - generate allure results for tests in cypress/integration/basicfolder
  • yarn test:prepare:cucumber - generate allure results for tests in cypress/integration/cucumber folder
  • test - run tests from cypress/integration/results against these allure results

Credits

A lot of respect to Sergey Korol who made Allure-mocha reporter. Major part of interaction from mocha to allure is based on that solution technically and ideologically.

License

Copyright 2020 Oleksandr Shevtsov [email protected].
This project is licensed under the Apache 2.0 License.