# aft-jira

> Automated Functional Testing (AFT) package supporting Jira integration for test execution control and logging

Latest version **12.1.1** (published 2024-05-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install aft-jira
pnpm add aft-jira
yarn add aft-jira
bun add aft-jira
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 12.1.1 |
| Published | 2024-05-23 |
| First published | 2024-03-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 155.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jason Holt Smith |
| Maintainers | bicarbon8 |
| Keywords | aft, automation, e2e, integration, functional, jira |

## Links

- npm: https://www.npmjs.com/package/aft-jira
- Repository: https://github.com/bicarbon8/automated-functional-testing
- Homepage: https://github.com/bicarbon8/automated-functional-testing#readme
- Issues: https://github.com/bicarbon8/automated-functional-testing/issues
- npm.io page: https://npm.io/package/aft-jira

## Dependencies (1)

- [aft-web-services](https://npm.io/package/aft-web-services.md) ^12.1.1

## Alternatives

- [@snazzah/davey](https://npm.io/package/@snazzah/davey.md) — 1.5M weekly downloads
- [@vendure/testing](https://npm.io/package/@vendure/testing.md) — 8.3K weekly downloads
- [vue-simple-context-menu](https://npm.io/package/vue-simple-context-menu.md) — 6.6K weekly downloads
- [cypress-webpack-preprocessor-v5](https://npm.io/package/cypress-webpack-preprocessor-v5.md) — 2.1K weekly downloads
- [@backstage/plugin-catalog-backend-module-puppetdb](https://npm.io/package/@backstage/plugin-catalog-backend-module-puppetdb.md) — 1.3K weekly downloads

## Recent versions

- 12.1.1 (latest) — 2024-05-23
- 12.1.0 — 2024-05-17
- 12.0.1 — 2024-05-16
- 12.0.0 — 2024-05-15
- 11.2.1 — 2024-05-10
- 11.2.0 — 2024-05-09
- 11.1.1 — 2024-05-07
- 11.1.0 — 2024-04-18
- 11.0.0 — 2024-04-12
- 10.3.0 — 2024-03-28

## README

# AFT-Jira
provides Jira result logging as well as test execution filtering for users of `aft-core` by implementing plugins for the `ReportingPlugin` and `PolicyPlugin` plugin base classes.

## JiraReportingPlugin
the `JiraReportingPlugin` extends from `ReportingPlugin` in `aft-core`. if enabled, this plugin will, upon receiving a failing test result, check for any existing open defects referencing the Test ID and if found, add a comment that the issue still exists or, if not found, will mark the defect as resolved. it can be enabled by including the following in your `aftconfig.json` file:
```json
{
    "logLevel": "info",
    "plugins": [
        {"name": "jira-reporting-plugin", "searchDir": "./node_modules"}
    ],
    "JiraConfig": {
        "url": "https://your.jira.instance/",
        "accesskey": "your_jira_access_token",
        "openDefectOnFail": false,
        "closeDefectOnPass": false,
        "projectKey": "ABCD",
        "closedStatusCategoryName": "Done"
    }
}
```
**JiraConfig**:
- **url** - `string` the url of your Jira instance
- **accesskey** - `string` a valid API access token created under your Profile section in Jira
- **openDefectOnFail** - `bool` if set to `true` a new defect will be created if a failed test result is received and not existing defect is found for the Test ID _(defaults to `false`)_
- **closeDefectOnPass** - `bool` if set to `true` and a passing test result is received and an open defect is found for the Test ID then the defect will be closed as resolved, fixed _(defaults to `false`)_
- **projectKey** - `string` the Jira project key (value displayed after `projects` in the URL when viewing the Jira Project) in which new issues will be created if `openDefectOnFail` is `true`
- **closedStatusCategoryName** - `string` containing the name visible in the UI for closed Jira issues. this is used to lookup open issues and when transitioning issues to a closed state if `closeDefectOnPass` is `true`. _(defaults to `"Done"`)_

## JiraPolicyPlugin
the `JiraPolicyPlugin` extends from `PolicyPlugin` interface in `aft-core`. if enabled this plugin will search Jira for open defects referencing the specified Test IDs from the set of IDs specified in a `AftTest` and if found this plugin will return a result of `false` from the `shouldRun` function. it can be enabled by including the following in your `aftconfig.json` file:
```json
{
    "logLevel": "info",
    "plugins": [
        {"name": "jira-policy-plugin", "searchDir": "./node_modules"}
    ],
    "JiraConfig": {
        "url": "https://your.jira.instance/",
        "accesskey": "your_jira_access_token",
        "policyEngineEnabled": true
    }
}
```
## Configuration
to open or modify defects in Jira, you will need to have an account with both read and write permissions. These values can be specified in your `aftconfig.json` as follows:
```json
{
    "JiraConfig": {
        "url": "http://fake.jira.io",
        "accesskey": "your_jira_access_token",
        "policyEngineEnabled": true
    }
}
```
- **url** - [REQUIRED] the full URL to your instance of Jira. _(**NOTE:** this is **NOT** the API URL, just the base domain name)_
- **accesskey** - `string` a valid API access token created under your Profile section in Jira
- **policyEngineEnabled** - `bool` if set to `true` then any `AftTest` with a Test ID will first check that the test should be run via this plugin. any open defects referencing this Test ID will result in a `false` response _(defaults to `true`)_

## Usage
you can submit results directly by calling the `aft-core.ReportingManager.submitResult(result: TestResult)` function or results will automatically be submitted if using the `aft-core.AftTest(description, testFunction)` with valid `testCases` specified in the `options` object. 

### via `aft-core.ReportingManager`:
```typescript
let reporter = new ReportingManager({logName: 'example'});
await reporter.submitResult({
    testId: 'C3190',
    status: TestStatus.Failed,
    resultMessage: 'there was an error when running this test'
});
```
### via `aft-core.AftTest` (`aft-core.AftTest.run()`):
```typescript
/** 
 * new Jira Issue opened for `C3190`, `C2217763`, and `C3131`
 * following execution because `AftTest.status` on exit is `failed`
 * and `verify` call doesn't reference any test IDs
 * #### NOTE:
 * > if open defects exist then a comment is added indicating
 * the issue still occurs instead of creating a duplicate issue
 */
await aftTest('[C3190][C2217763][C3131]', async (t: AftTest) => {
    await t.verify((1 + 1), 3, 'expected to fail because 1+1 != 3');
});
```

---
_Source: https://npm.io/package/aft-jira · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
