Socket
Socket
Sign inDemoInstall

@isaac.frontend/testcafe-reporter-allure

Package Overview
Dependencies
Maintainers
7
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@isaac.frontend/testcafe-reporter-allure - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

15

CHANGELOG.md

@@ -6,2 +6,17 @@ # Changelog

### [1.0.3](https://github.com/isaaceindhoven/testcafe-reporter-allure/compare/v1.0.2...v1.0.3) (2020-07-30)
### Chores
* **husky:** only run linting on pre-commit ([de6de72](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/de6de723f9b8c042cb1b9496794e134912f8b0da))
* **husky:** remove unused pre-commit comment ([7005776](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/70057762e64676d41b967436b61deb832fdc50aa))
### Documentation
* **all:** implement vuepress for documentation ([7d13571](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/7d13571bfbcc6b3471814874b431315f8528c41c))
* **README:** Enriched JS snippets ([9bc34ca](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/9bc34ca95e98e4802bcf368d3fbc88a447e171fd))
* **README:** Fix module.export typo ([9089c08](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/9089c0896e975768e68342543bf63534ff797f7a))
### [1.0.2](https://github.com/isaaceindhoven/testcafe-reporter-allure/compare/v1.0.1...v1.0.2) (2020-07-29)

@@ -8,0 +23,0 @@

19

package.json
{
"name": "@isaac.frontend/testcafe-reporter-allure",
"version": "1.0.2",
"version": "1.0.3",
"author": "ISAAC E-commerce Solutions BV",

@@ -36,9 +36,6 @@ "license": "MIT",

"semantic-release": "semantic-release",
"pack:contents": "npm pack && tar -xvzf *.tgz && rm -rf package *.tgz"
"pack:contents": "npm pack && tar -xvzf *.tgz && rm -rf package *.tgz",
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"files": [

@@ -53,2 +50,4 @@ "dist/*"

"devDependencies": {
"@commitlint/cli": "^9.1.1",
"@commitlint/config-conventional": "^9.1.1",
"@rollup/plugin-typescript": "5.0.2",

@@ -66,5 +65,2 @@ "@semantic-release/changelog": "5.0.1",

"callsite-record": "4.1.3",
"commitizen": "4.1.2",
"conventional-changelog-conventionalcommits": "4.3.0",
"cz-conventional-changelog": "3.2.0",
"eslint": "7.5.0",

@@ -86,4 +82,5 @@ "eslint-config-airbnb-typescript": "9.0.0",

"ts-jest": "26.1.4",
"typescript": "3.9.7"
"typescript": "3.9.7",
"vuepress": "^1.5.2"
}
}
# @isaac.frontend/testcafe-reporter-allure
[![GitHub](https://img.shields.io/github/license/isaaceindhoven/testcafe-reporter-allure)](https://github.com/isaaceindhoven/testcafe-reporter-allure/blob/master/LICENSE) [![NPM downloads per week](https://img.shields.io/npm/dw/@isaac.frontend/testcafe-reporter-allure)](https://www.npmjs.com/package/@isaac.frontend/testcafe-reporter-allure) [![npm (scoped)](https://img.shields.io/npm/v/@isaac.frontend/testcafe-reporter-allure)](https://www.npmjs.com/package/@isaac.frontend/testcafe-reporter-allure) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
This project is an [Allure](https://allure.qatools.ru/) reporter plugin for [TestCafé](https://devexpress.github.io/testcafe/).
An [Allure](https://allure.qatools.ru/) reporter plugin for [TestCafé](https://devexpress.github.io/testcafe/).
The inspiration for this project was its namesake, [testcafe-reporter-allure](https://www.npmjs.com/package/testcafe-reporter-allure), made by azohra-core, making use of the 2.0.0 version of the [allure-js-commons](https://github.com/allure-framework/allure-js/tree/master/packages/allure-js-commons) package.
## Documentation
## Contents
- [Installation](#installation)
- [Using the reporter](#using-the-reporter)
- [Features](#features)
- [Metadata](#metadata)
- [Test Steps](#test-steps)
- [Jenkins](#jenkins)
- [Configuration](#configuration)
- [Concurrency and Multi-Browser test-runs](#concurrency-and-multi-browser-test-runs)
- [Contributing](#contributing)
- [License](#license)
https://isaaceindhoven.github.io/testcafe-reporter-allure
## Installation
This package is namespaced. Therefore the following command can be used to install the reporter in a way that TestCafé can detect it.
([Related ISSUE](https://github.com/DevExpress/testcafe/issues/4692))
`npm install --save-dev testcafe-reporter-allure@npm:@isaac.frontend/testcafe-reporter-allure`
The [Allure Commandline](https://www.npmjs.com/package/allure-commandline) is needed to convert the Allure-Results into an Allure-Report. This package can be installed with the following command:
`npm install --save-dev allure-commandline`
Quick install of all dependencies:
`npm install --save-dev allure-commandline testcafe testcafe-reporter-allure@npm:@isaac.frontend/testcafe-reporter-allure`
## Using the reporter
The reporter can then be loaded in two separate ways:
When using TestCafé via the command line, the reporter can be specified by using the `--reporter` option.
`testcafe chrome 'path/to/test/file.js' --reporter allure --screenshots path=allure/screenshots,takeOnFails=true`
When using TestCafé via the API, the reporter can be specified by either passing the reporter name or the reporter object in the `reporter()` method within the `runner.js` file.
```
testCafe
.createRunner()
.src(['tests/e2e/*.ts'])
.browsers('firefox')
.reporter('allure')
.run();
```
or
```
const allureReporter = require('testcafe-reporter-allure');
testCafe
.createRunner()
.src(['tests/e2e/*.ts'])
.browsers('firefox')
.reporter(allureReporter)
.run();
```
After the Allure-Results are generated, the Allure-Report can be built:
`allure generate ./allure/allure-results --clean -o ./allure/allure-report && allure open ./allure/allure-report`
## Features
### Metadata
![Example of the metadata code shown below.](https://raw.githubusercontent.com/isaaceindhoven/testcafe-reporter-allure/master/.github/images/metadata.PNG)
Metadata can be added to a test by using the `meta()` function. The metadata can be added to both the `test` and the `fixture`.
Metadata added to a `fixture` will be inherited by all tests coupled to that fixture to avoid having to declare metadata that is the same for all tests within the fixture multiple times.
```
test.meta({
severity: Severity.TRIVIAL,
issue: 'TEST-ISSUE',
description: 'An example discription',
epic: 'Example Epic Ticket',
feature: 'Example Feature Ticket',
story: 'Example Story Ticket',
suite: 'Main Example Group',
otherMeta: 'Example otherMeta parameter.',
})('Example test with metadata', async (t) => {
// Test Code
});
```
| Metadata | Description |
| ------------- | ------------- |
| Severity | The severity values are dictated by the [allure-js-commons](https://github.com/allure-framework/allure-js/tree/master/packages/allure-js-commons) package, these values are: `blocker, critical, normal, minor, trivial`; |
| Issue | A Jira Issue can be coupled to a test, creating a link within the Allure Report to the Jira Issue page. The URL to the Jira page can be set in the [allure-js-commons](https://github.com/isaaceindhoven/testcafe-reporter-allure#configuration). |
| Epic, Feature, Story | To sort the tests based on the `epic`, `feature`, and/or `story`, these metadata options can be used to form a tree structure. The tree is structured as follows: An epic can have multiple features, a feature can have multiple stories, and a story can have multiple tests. |
| Suite | Within the Allure Report, the tests are organized by `fixture` by default. For a more expansive organization of the tests and fixtures, the `suite` parameter can be set. When the `suite` parameter is set within a `test`, a subcategory is created within the `fixture` that will group all tests that have the same `suite` parameter together. When the `suite` parameter is set within a `fixture`, a parent category is created that will group multiple fixtures that have the same `suite` parameter. |
| Othermeta | It is also possible to add custom metadata to a `test`. These will be added as parameters to the Allure Report. These parameters do __NOT__ have to be named otherMeta but do require to be a key-value pair of two strings. For example, adding a color parameter to a test: `color: 'black'` will result in `color: black` be added to the final Allure Report. |
### Test Steps
![Example of the step code shown below.](https://raw.githubusercontent.com/isaaceindhoven/testcafe-reporter-allure/master/.github/images/test-steps.PNG)
With this reporter, test-steps can be defined to split a TestCafé `test` into multiple steps. The step function expects three variables: The step name, the TestController, and the actions taken within the step as a TestControllerPromise.
These steps will show up as test-steps within the Allure-Report and will include a screenshot of the page state at the end of the step. These screenshots could then be used to visually follow along with what the test does within each step and get a quick overview where a test might be failing.
```
import step from 'testcafe-reporter-allure';
test('Example test with steps', async (t) => {
await step('Add developer name to form', t,
t.typeText('#developer-name', 'John Smith')
);
await step('Submit form and check result', t,
t.click('#submit-button')
.expect(Selector('#article-header')
.innerText).eql('Thank you, John Smith!'),
);
});
```
### Jenkins
Because the testcafe-reporter-allure package used Allure to visualize the reports, it is also compatible with the [Allure-Jenkins](https://plugins.jenkins.io/allure-jenkins-plugin/) allowing for the reports to be added to each pipeline run.
An example [Jenkinsfile](https://github.com/isaaceindhoven/testcafe-reporter-allure/blob/master/examples/base-implementation/Jenkinsfile) implementing this can be found in the [examples/base-implementation](https://github.com/isaaceindhoven/testcafe-reporter-allure/tree/master/examples/base-implementation). These pipeline stages can be added to your own projects Jenkinsfile to implement the plugins features. Within the `test:e2e` stage, the environment property `TESTCAFE_BROWSER` can be set to define the browser used within the test run.
Do note that these browsers behave differently because they are running within a docker container. For example, Chrome needs the `--no-sandbox` tag to function properly; otherwise, the following error will occur: `Error: Unable to establish one or more of the specified browser connections. This can be caused by network issues or remote device failure.` This issue is further detailed [here](https://github.com/DevExpress/testcafe/issues/1133#issuecomment-350775990).
To avoid running the browsers within the docker container, using a service like [BrowserStack]( https://devexpress.github.io/testcafe/documentation/guides/concepts/browsers.html#browsers-in-cloud-testing-services) is recommended.
Lastly, all browsers have to be run in `:headless` mode, as can be seen within the Jenkinsfile example.
## Configuration
Testcafe-reporter-allure provides a sensible default for the configuration. However, if a different configuration is needed, this default can be overridden by creating the file `allure.config.js` and/or `allure-categories.config.js` in the root of your project. The `allure.config.js` is for the base configuration options, and the `allure-categories.config.js` is specifically for editing the [categories](https://docs.qameta.io/allure/#_categories) config used by the Allure Commandline to sort the tests based on pattern matching.
An example `allure.config.js`:
```
module.export = {
RESULT_DIR: './allure/allure-results',
REPORT_DIR: './allure/allure-report',
SCREENSHOT_DIR: './allure/screenshots',
CLEAN_RESULT_DIR: true,
CLEAN_REPORT_DIR: true,
CLEAN_SCREENSHOT_DIR: true,
ENABLE_SCREENSHOTS: true,
ENABLE_QUARANTINE: false,
ENABLE_LOGGING: false,
CONCURRENCY: 1,
META: {
SEVERITY: 'Normal',
ISSUE_URL: 'https://jira.example.nl/browse/',
},
LABEL: {
ISSUE: 'JIRA Issue',
FLAKY: 'Flaky test',
SCREENSHOT_MANUAL: 'Screenshot taken manually',
SCREENSHOT_ON_FAIL: 'Screenshot taken on fail',
DEFAULT_STEP_NAME: 'Test step',
},
};
```
An example `allure-categories.config.js`:
```
module.export = [
{
name: 'Ignored tests',
matchedStatuses: [Status.SKIPPED],
},
{
name: 'Product defects',
matchedStatuses: [Status.FAILED],
messageRegex: '.*Assertion failed.*',
},
{
name: 'Test defects',
matchedStatuses: [Status.FAILED],
},
{
name: 'Warnings',
matchedStatuses: [Status.PASSED],
messageRegex: '.*Warning.*',
},
{
name: 'Flaky tests',
matchedStatuses: [Status.PASSED, Status.FAILED],
messageRegex: '.*Flaky.*',
},
];
```
### Concurrency and Multi-Browser test-runs
The testcafe-allure-reporter supports both TestCafé's concurrency and multi-browser test-run features these can both be set using either the runner.js with the TestCafé API or the TestCafé CLI. Also, the concurrency can be set via the `allure.config.js` file, as seen in the previous chapter.
NOTE: Concurrency regards the number of browser instances opened PER browser. For example, if the concurrency is 5, and both Firefox and Chrome are used, TestCafé will open 5 Firefox and 5 Chrome instances.
With the API in the runner.js, multiple browsers can be set by passing them as an array into the `.browsers()` function. Concurrency can be set by passing a number into the `.concurrency()` function.
```
const allureReporter = require('testcafe-reporter-allure');
testCafe
.createRunner()
.src(['tests/e2e/*.ts'])
.browsers([firefox:headless, chrome:headless]) <--
.reporter(allureReporter)
.concurrency(1) <--
.run();
```
With the CLI multiple browsers can be added to the `testcafe` command separated with a comma without a tag. For example: `testcafe chrome,firefox`. Also all local browsers can be run a once by using the `all` alias instead of seperate browsers.
The concurrency can be set within the commandline with the `-c or --concurrency` tag. For example: `testcafe --concurrency 5`.
## Contributing

@@ -228,0 +11,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc