2.15.1 • Published 1 month ago

allure-decorators v2.15.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 month ago

Allure Decorators

This project introduces TS decorators integration for Allure framework.

Installation based on allure-mocha reporter

npm i allure-js-commons allure-decorators allure-mocha @testdeck/mocha mocha @types/mocha mocha-multi-reporters source-map-support --save-dev

or via yarn:

yarn add allure-js-commons allure-decorators allure-mocha @testdeck/mocha mocha @types/mocha mocha-multi-reporters source-map-support --dev

Usage

Create the following .mocharc.json:

{
  "require": "source-map-support/register",
  "spec": "./src/tests/**/*.js",
  "reporter": "mocha-multi-reporters",
  "reporter-option": "configFile=reporterConfig.json"
}

And the reporterConfig.json:

{
  "reporterEnabled": "allure-mocha, list",
  "allureMochaReporterOptions": {
    "resultsDir": "./allure-results"
  }
}

Note that there are known issues with Mocha 8+ parallel test execution. So try to avoid using this flag at the moment.

Your tsconfig.json must include the following compiler options:

{
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true
  }
}

Now your test may look like the following:

import { suite, test } from '@testdeck/mocha'
import {
  assignPmsUrl,
  assignTmsUrl,
  data,
  decorate,
  description,
  epic,
  feature,
  issue,
  owner,
  severity,
  story,
  tag,
  testCaseId
} from 'allure-decorators'
import { ContentType, Severity } from 'allure-js-commons'
import { allure, MochaAllure } from 'allure-mocha/runtime'
// the other imports

@suite
class AuthorizationTests {

  public static testData = (): User[] => {
    return [User.dummy(), User.dummy1()]
  }

  @issue('11')
  @testCaseId('10')
  @severity(Severity.BLOCKER)
  @epic('User Authentication')
  @feature('Login')
  @story('Authorization')
  @owner('skorol')
  @tag('smoke')
  @description('Basic authorization test.')
  @data(AuthorizationTests.testData)
  @data.naming(user => `${user} should be able to sign`)
  @test
  public userShouldBeAbleToSignIn(user: User) {
    open(LoginPage)
      .loginWith(user)
      .select(ProfilePage)

    verifyThat(atProfilePage)
      .fullNameIs(user.fullName)
      .usernameIs(user.username)
  }

  public before() {
    decorate<MochaAllure>(allure)
    assignTmsUrl(process.env.TMS_URL)
    assignPmsUrl(process.env.PMS_URL)
  }

  public after() {
    allure.attachment('Test attachment', 'test attachment content', ContentType.TEXT)
  }
}

You should pay attention to the following line:

decorate<MochaAllure>(allure)

To be able to use decorators, you have to call decorate function explicitly and set your reporter's instance in before hook. This was done intentionally to allow clients decide which reporter they want to use with decorators module.

Note that data is a testdeck specific extension which allows injecting parameters into Allure scope. At the moment, testdeck supports only Mocha, Jest and Jasmine frameworks. If you want to add the other integration, feel free to contact Allure team to discuss the potential design options.

ToDo

  • Update mocha-allure2-example with new allure-decorators dependency.
  • Explore potential data decorator extension for the other frameworks.
2.15.1

1 month ago

2.15.0

2 months ago

2.14.1

2 months ago

2.14.0

2 months ago

2.13.0

2 months ago

2.12.2

3 months ago

2.11.3

3 months ago

2.12.1

3 months ago

2.12.0

3 months ago

2.11.1

4 months ago

2.11.0

4 months ago

2.10.0

5 months ago

2.5.0

9 months ago

2.7.0

8 months ago

2.6.0

9 months ago

2.9.0

7 months ago

2.8.1

8 months ago

2.8.0

8 months ago

2.9.2

7 months ago

2.9.1

7 months ago

2.3.0

12 months ago

2.4.0

12 months ago

2.2.1

1 year ago

2.2.0

1 year ago

2.1.0

1 year ago

2.0.0-beta.22

1 year ago

2.0.0-beta.21

1 year ago

2.0.0-beta.26

1 year ago

2.0.0-beta.25

1 year ago

2.0.0-beta.24

1 year ago

2.0.0-beta.23

1 year ago

2.0.0

1 year ago

2.0.0-beta.20

1 year ago

2.0.0-beta.19

2 years ago

2.0.0-beta.18

2 years ago

2.0.0-beta.17

2 years ago

2.0.0-beta.16

2 years ago

2.0.0-beta.15

2 years ago

2.0.0-beta.14

3 years ago

2.0.0-beta.13

3 years ago

2.0.0-beta.12

3 years ago

2.0.0-beta.11

3 years ago