Skip to content

Commit

Permalink
docs: update readme to match v3 and have a common pattern (via #1180)
Browse files Browse the repository at this point in the history
  • Loading branch information
delatrie authored Oct 31, 2024
1 parent 2454d0c commit 9584104
Show file tree
Hide file tree
Showing 9 changed files with 555 additions and 825 deletions.
202 changes: 66 additions & 136 deletions packages/allure-codeceptjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,173 +12,103 @@

---

## Installation

```bash
npm i -D allure-codeceptjs
```
## The documentation and examples

## Usage
The docs for Allure CodeceptJS are available at [https://allurereport.org/docs/codeceptjs/](https://allurereport.org/docs/codeceptjs/).

Add the allure plugin inside you plugins section of your CodeceptJS config file.
For instance the config file is `codecept.config.(js|ts)` then:
Also, check out the examples at [github.com/allure-examples](https://github.com/orgs/allure-examples/repositories?q=visibility%3Apublic+archived%3Afalse+topic%3Aexample+topic%3Acodeceptjs).

```js
module.exports.config = {
plugins: {
// ...
allure: {
enabled: true,
require: "allure-codeceptjs",
},
// ...
}
};
```

## Allure Runtime API usage
## Installation

Right now you can access allure API through codeceptjs container.
Install `allure-codeceptjs` using a package manager of your choice. For example:

```js
import { label, tag, tags, issue, owner, layer, allureId, description, story, feature, epic, attachment } from "allure-js-commons";

Feature("login-feature");
Scenario("login-scenario1", async () => {
await label("name", "value");
await tag("tag1");
await tags("tag2", "tag3");
await issue("issueName", "google.com");
await owner("eroshenkoam");
await layer("UI");
await allureId("228");
await description("aga");
await story("aga");
await feature("aga");
await epic("aga");
await attachment("data.txt", "some data", "text/plain");
});
```bash
npm install -D allure-codeceptjs
```

You can also use tags to manage labels on scenarios.
## Usage

## Links usage
Enable the `allure` plugin in [the CodeceptJS configuration file](https://codecept.io/configuration/):

```js
import { link, issue, tms } from "allure-js-commons";

Feature("login-feature");
Scenario("login-scenario1", async () => {
await link("link_type", "https://allurereport.org", "Allure Report");
await issue("Issue Name", "https://github.com/allure-framework/allure-js/issues/352");
await tms("Task Name", "https://github.com/allure-framework/allure-js/tasks/352");
});
```

You can also configure links formatters to make usage much more convenient. `%s`
in `urlTemplate` parameter will be replaced by given value.

```diff
module.exports.config = {
// ...
plugins: {
allure: {
enabled: true,
require: "allure-codeceptjs",
+ links: [
+ {
+ type: "${LinkType.ISSUE}",
+ urlTemplate: "https://example.org/issues/%s",
+ nameTemplate: "Issue: %s",
+ },
+ {
+ type: "${LinkType.TMS}",
+ urlTemplate: "https://example.org/tasks/%s",
+ }
+ ]
},

// Other plugins...
},
// ...

// Other CodeceptJS options...
};
```

Then you can assign link using shorter notation:
When the test run completes, the result files will be generated in the `./allure-results` directory.

```js
import { link, issue, tms } from "allure-js-commons";

Feature("login-feature");
Scenario("login-scenario1", async () => {
await issue("351");
await issue("352", "Issue Name");
await tms("351");
await tms("352", "Task Name");
await link("custom", "352");
await link("custom", "352", "Link name");
});
```
You may select another location, or further customize the plugin's behavior with [the configuration options](https://allurereport.org/docs/codeceptjs-configuration/).

## Tags metadata API
### View the report

You also can mark up your tests with Allure metadata using CodeceptJS tags API.
> You need Allure Report to be installed on your machine to generate and open the report from the result files. See the [installation instructions](https://allurereport.org/docs/install/) on how to get it.
### Id

```javascript
Feature("login-feature");
Scenario("login-scenario1", async () => {
// your test
}).tag("@allure.id:228");
```
Generate Allure Report after the tests are executed:

### Label

```javascript
Feature("login-feature");
Scenario("login-scenario1", async () => {
// your test
}).tag("@allure.label.{{labelName}}:{{labelValue}}");
```bash
allure generate ./allure-results -o ./allure-report
```

### Story
Open the generated report:

```javascript
Feature("login-feature");
Scenario("login-scenario1", async () => {
// your test
}).tag("@allure.label.story:storyName");
```
### Suite

```javascript
Feature("login-feature");
Scenario("login-scenario1", async () => {
// your test
}).tag("@allure.label.suite:suiteName");
```bash
allure open ./allure-report
```

### Owner
## Allure API

```javascript
Feature("login-feature");
Scenario("login-scenario1", async () => {
// your test
}).tag("@allure.label.owner:ownerName");
```

### Tag
Enhance the report by utilizing the Allure API:

```javascript
Feature("login-feature");
Scenario("login-scenario1", async () => {
// your test
}).tag("@allure.label.tag:tagName");
```js
import * as allure from "allure-js-commons";

Feature("Signing in with a password");
Scenario("Signing in with a correct password", async () => {
await allure.description("The test checks if an active user with a valid password can sign in to the app.");
await allure.epic("Signing in");
await allure.tags("signin", "ui", "positive");
await allure.issue("https://github.com/allure-framework/allure-js/issues/673", "ISSUE-673");
await allure.owner("eroshenkoam");
await allure.parameter("browser", "chrome");

const user = await allure.step("Prepare the user", async () => {
return await createAnActiveUserInDb();
});

await allure.step("Make a sign-in attempt", async () => {
await allure.step("Navigate to the sign-in page", async () => {
// ...
});

await allure.step("Fill the sign-in form", async (stepContext) => {
await stepContext.parameter("login", user.login);
await stepContext.parameter("password", user.password, "masked");

// ...
});

await allure.step("Submit the form", async () => {
// ...
// const responseData = ...

await allure.attachment("response", JSON.stringify(responseData), { contentType: "application/json" });
});
});

await allure.step("Assert the signed-in state", async () => {
// ...
});
});
```
or keep it simple:

```javascript
Feature("login-feature");
Scenario("login-scenario1", async () => {
// your test
}).tag("tagName");
```
More details about the API are available at [https://allurereport.org/docs/codeceptjs-reference/](https://allurereport.org/docs/codeceptjs-reference/).
Loading

0 comments on commit 9584104

Please sign in to comment.