Skip to content

Commit

Permalink
EPMRPP-78272 || Implement attaching data using attach
Browse files Browse the repository at this point in the history
  • Loading branch information
Dzmitry Kosarau authored and Dzmitry Kosarau committed Oct 10, 2023
1 parent 5a69065 commit 2066a71
Show file tree
Hide file tree
Showing 14 changed files with 518 additions and 24 deletions.
5 changes: 3 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module",
"project": "./tsconfig.eslint.json"
"project": "./tsconfig.eslint.json"
},
"rules": {
"no-plusplus": 0,
Expand All @@ -33,6 +33,7 @@
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/no-implied-eval": 0,
"dot-notation": 0,
"@typescript-eslint/naming-convention": 0
"@typescript-eslint/naming-convention": 0,
"consistent-return": "warn"
}
}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.md
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
### Added
- Add ability to provide `attributes`,`status`,`description`,`testCaseId` for test using `testInfo.attach`

## [5.1.4] - 2023-10-05
## Changed
Expand Down
63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,69 @@ test('basic test', async ({ page }, testInfo) => {
});
```

Also, we can attach `attributes`,`status`,`description`,`testCaseId`

`Description`
```typescript
import { test, expect } from '@playwright/test';
import { RPTestInfo } from '@reportportal/agent-js-playwright'

test('basic test', async ({ page }, testInfo) => {
await testInfo.attach(RPTestInfo.description, { body: 'Description', contentType: 'plain/text' });

expect(true).toBe(true);
});
```
Description provided this way will be merged with description provided by `ReportingAPI`.

`Attributes`
```typescript
import { test, expect } from '@playwright/test';
import { RPTestInfo } from '@reportportal/agent-js-playwright'

test('basic test', async ({ page }, testInfo) => {
await testInfo.attach(RPTestInfo.status, { body: JSON.stringify([
{
key: 'testKey',
value: 'testValue',
},
{
value: 'testValueTwo',
}
]),
contentType: 'application/json' });

expect(true).toBe(true);
});
```
Attributes provided this way will be merged with Attributes provided by `ReportingAPI`.

`Status`
```typescript
import { test, expect } from '@playwright/test';
import { RPTestInfo } from '@reportportal/agent-js-playwright'

test('basic test', async ({ page }, testInfo) => {
await testInfo.attach(RPTestInfo.status, { body: 'passed', contentType:'text/plain'})

expect(true).toBe(true);
});
```
Status provided this way will be replaced by status provided by `ReportingAPI`. You can provide as many statuses as you want, but only the last will be applied.

`testCaseId`
```typescript
import { test, expect } from '@playwright/test';
import { RPTestInfo } from '@reportportal/agent-js-playwright'

test('basic test', async ({ page }, testInfo) => {
await testInfo.attach(RPTestInfo.testCaseId, { body: 'testCaseId', contentType:'text/plain'})

expect(true).toBe(true);
});
```
TestCaseId provided this way will be replaced by testCaseId provided by `ReportingAPI`.

*Note:* attachment path can be provided instead of body.

As an alternative to this approach the [`ReportingAPI`](#log) methods can be used.
Expand Down
137 changes: 124 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"lint": "eslint \"src/**/*.ts\"",
"format": "npm run lint -- --fix",
"test": "jest",
"test:coverage": "jest --coverage"
"test:coverage": "jest --coverage",
"examples": "npm run build && npm explore examples -- npm run test:basic"
},
"dependencies": {
"@reportportal/client-javascript": "^5.0.14",
Expand All @@ -21,6 +22,7 @@
],
"devDependencies": {
"@playwright/test": "^1.37.1",
"examples": "../examples-js/example-playwright",
"@types/jest": "^27.5.2",
"@types/node": "^18.14.2",
"@typescript-eslint/eslint-plugin": "^4.33.0",
Expand Down
Loading

0 comments on commit 2066a71

Please sign in to comment.