monocart-reporter 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -51
- package/lib/plugins/comments.js +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -61,8 +61,6 @@
|
|
|
61
61
|
|
|
62
62
|

|
|
63
63
|
|
|
64
|
-
[More Test Reports](https://github.com/cenfun/monocart-reporter-test)
|
|
65
|
-
|
|
66
64
|
## Install
|
|
67
65
|
```sh
|
|
68
66
|
npm i -D monocart-reporter
|
|
@@ -86,7 +84,8 @@ Playwright Docs [https://playwright.dev/docs/test-reporters](https://playwright.
|
|
|
86
84
|
|
|
87
85
|
## Examples
|
|
88
86
|
- [tests](/tests/)
|
|
89
|
-
- [
|
|
87
|
+
- More Examples [monocart-reporter-examples](https://github.com/cenfun/monocart-reporter-examples)
|
|
88
|
+
|
|
90
89
|
## Output
|
|
91
90
|
- path-to/your-filename.html
|
|
92
91
|
Single HTML file (data compressed), easy to transfer/deploy or open directly anywhere
|
|
@@ -318,6 +317,12 @@ module.exports = {
|
|
|
318
317
|
|
|
319
318
|
For example, adding `owner` and `jira` to the cases, steps, and suites. or updating the value if the field exists like `title`
|
|
320
319
|
```js
|
|
320
|
+
/**
|
|
321
|
+
* for file (comment file in the first line)
|
|
322
|
+
* @owner FO
|
|
323
|
+
*/
|
|
324
|
+
const { test, expect } = require('@playwright/test');
|
|
325
|
+
|
|
321
326
|
/**
|
|
322
327
|
* for case
|
|
323
328
|
* @owner Kevin
|
|
@@ -337,20 +342,27 @@ test('case description', () => {
|
|
|
337
342
|
|
|
338
343
|
});
|
|
339
344
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
345
|
+
/**
|
|
346
|
+
* for describe suite
|
|
347
|
+
* @owner Mark
|
|
348
|
+
* @jira MCR-16900
|
|
349
|
+
*/
|
|
350
|
+
test.describe('suite title', () => {
|
|
351
|
+
|
|
352
|
+
test('case title', ({ browserName }, testInfo) => {
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* rewrite assert step title "expect.toBe" to
|
|
356
|
+
* @title my custom assert step title
|
|
357
|
+
* @annotations important
|
|
358
|
+
*/
|
|
359
|
+
expect(testInfo).toBe(test.info());
|
|
360
|
+
|
|
361
|
+
// @owner Steve
|
|
362
|
+
await test.step('step title', () => {
|
|
363
|
+
|
|
364
|
+
});
|
|
365
|
+
|
|
354
366
|
});
|
|
355
367
|
|
|
356
368
|
});
|
|
@@ -371,23 +383,6 @@ test.beforeEach(() => {
|
|
|
371
383
|
|
|
372
384
|
});
|
|
373
385
|
```
|
|
374
|
-
```js
|
|
375
|
-
/**
|
|
376
|
-
* for describe
|
|
377
|
-
* @owner Mark
|
|
378
|
-
* @jira MCR-16900
|
|
379
|
-
*/
|
|
380
|
-
test.describe('suite title', () => {
|
|
381
|
-
|
|
382
|
-
});
|
|
383
|
-
```
|
|
384
|
-
```js
|
|
385
|
-
/**
|
|
386
|
-
* for file (comment file in the first line)
|
|
387
|
-
* @owner FO
|
|
388
|
-
*/
|
|
389
|
-
const { test, expect } = require('@playwright/test');
|
|
390
|
-
```
|
|
391
386
|
|
|
392
387
|
### Custom Data Visitor
|
|
393
388
|
The `visitor` function will be executed for each row item (suite, case and step). Arguments:
|
|
@@ -420,7 +415,7 @@ module.exports = {
|
|
|
420
415
|
]
|
|
421
416
|
};
|
|
422
417
|
```
|
|
423
|
-
multiple matches example: [collect-data](https://github.com/cenfun/monocart-reporter-
|
|
418
|
+
multiple matches example: [collect-data](https://github.com/cenfun/monocart-reporter-examples/tree/main/tests/collect-data)
|
|
424
419
|
|
|
425
420
|
#### Collect Data from the Annotations
|
|
426
421
|
It should be easier than getting from title. see [custom annotations](https://playwright.dev/docs/test-annotations#custom-annotations) via `test.info().annotations`
|
|
@@ -481,7 +476,7 @@ module.exports = {
|
|
|
481
476
|
]
|
|
482
477
|
};
|
|
483
478
|
```
|
|
484
|
-
see example: [remove-secrets](https://github.com/cenfun/monocart-reporter-
|
|
479
|
+
see example: [remove-secrets](https://github.com/cenfun/monocart-reporter-examples/tree/main/tests/remove-secrets)
|
|
485
480
|
|
|
486
481
|
## Style Tags
|
|
487
482
|
* Add tag to test/describe title ( starts with `@` )
|
|
@@ -632,7 +627,7 @@ The reporter integrates [monocart-coverage-reports](https://github.com/cenfun/mo
|
|
|
632
627
|

|
|
633
628
|
|
|
634
629
|
### Global Coverage Report
|
|
635
|
-
The global coverage report will
|
|
630
|
+
The global coverage report will merge all coverages into one global report after all the tests are finished.
|
|
636
631
|
- The global coverage options see [Coverage Options](#coverage-options)
|
|
637
632
|
```js
|
|
638
633
|
// playwright.config.js
|
|
@@ -650,7 +645,7 @@ module.exports = {
|
|
|
650
645
|
]
|
|
651
646
|
};
|
|
652
647
|
```
|
|
653
|
-
-
|
|
648
|
+
- Adding coverage data for each test with [automatic fixtures](https://playwright.dev/docs/test-fixtures#automatic-fixtures)
|
|
654
649
|
```js
|
|
655
650
|
// fixtures.js for v8 coverage
|
|
656
651
|
import { test as testBase, expect } from '@playwright/test';
|
|
@@ -695,9 +690,46 @@ const test = testBase.extend({
|
|
|
695
690
|
});
|
|
696
691
|
export { test, expect };
|
|
697
692
|
```
|
|
693
|
+
- Adding server side coverage on global teardown
|
|
694
|
+
> For example, a Node.js web server start at the beginning of the test with the env `NODE_V8_COVERAGE=dir`, the V8 coverage data will be saved to `dir` with calling API `v8.takeCoverage()` manually or terminating server gracefully. On global teardown, reading all from `dir` and adding them to global coverage report. For Node.js, the V8 coverage data requires appending source manually.
|
|
695
|
+
```js
|
|
696
|
+
// global-teardown.js
|
|
697
|
+
import fs from 'fs';
|
|
698
|
+
import path from 'path';
|
|
699
|
+
import { fileURLToPath } from 'url';
|
|
700
|
+
import { addCoverageReport } from 'monocart-reporter';
|
|
701
|
+
|
|
702
|
+
export default async (config) => {
|
|
703
|
+
|
|
704
|
+
const dir = "your-v8-coverage-data-dir";
|
|
705
|
+
|
|
706
|
+
const files = fs.readdirSync(dir);
|
|
707
|
+
for (const filename of files) {
|
|
708
|
+
const content = fs.readFileSync(path.resolve(dir, filename)).toString('utf-8');
|
|
709
|
+
const json = JSON.parse(content);
|
|
710
|
+
let coverageList = json.result;
|
|
711
|
+
coverageList = coverageList.filter((entry) => entry.url && entry.url.startsWith('file:'));
|
|
712
|
+
|
|
713
|
+
// appending source
|
|
714
|
+
coverageList.forEach((entry) => {
|
|
715
|
+
entry.source = fs.readFileSync(fileURLToPath(entry.url)).toString('utf8');
|
|
716
|
+
});
|
|
717
|
+
|
|
718
|
+
// there is no test info on teardown, just mock one with required config
|
|
719
|
+
const mockTestInfo = {
|
|
720
|
+
config
|
|
721
|
+
};
|
|
722
|
+
await addCoverageReport(coverageList, mockTestInfo);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
```
|
|
726
|
+
see [Node.js V8 Coverage Report for Server Side](https://github.com/cenfun/monocart-coverage-reports?#nodejs-v8-coverage-report-for-server-side)
|
|
698
727
|
|
|
699
728
|
### Coverage Options
|
|
700
729
|
- Default [options](https://github.com/cenfun/monocart-coverage-reports/blob/main/lib/default/options.js)
|
|
730
|
+
- [Available Reports](https://github.com/cenfun/monocart-coverage-reports?#available-reports)
|
|
731
|
+
- [Using entryFilter and sourceFilter to filter the results for V8 report](https://github.com/cenfun/monocart-coverage-reports?#using-entryfilter-and-sourcefilter-to-filter-the-results-for-v8-report)
|
|
732
|
+
- Checking thresholds with [onEnd Hook](https://github.com/cenfun/monocart-coverage-reports?#onend-hook)
|
|
701
733
|
- More Introduction [monocart-coverage-reports](https://github.com/cenfun/monocart-coverage-reports)
|
|
702
734
|
|
|
703
735
|
### Coverage Examples
|
|
@@ -875,7 +907,7 @@ module.exports = {
|
|
|
875
907
|
]
|
|
876
908
|
};
|
|
877
909
|
```
|
|
878
|
-
see example: [Allow specified test cases to run in sequence mode with lock/unlock state](https://github.com/cenfun/monocart-reporter-
|
|
910
|
+
see example: [Allow specified test cases to run in sequence mode with lock/unlock state](https://github.com/cenfun/monocart-reporter-examples/tree/main/tests/global-state)
|
|
879
911
|
|
|
880
912
|
## Merge Shard Reports
|
|
881
913
|
There will be multiple reports to be generated if Playwright test executes in sharding mode. for example:
|
|
@@ -908,7 +940,7 @@ await merge(reportDataList, {
|
|
|
908
940
|
}
|
|
909
941
|
});
|
|
910
942
|
```
|
|
911
|
-
|
|
943
|
+
see example [merge.js](https://github.com/cenfun/monocart-reporter-examples/blob/main/scripts/merge.js)
|
|
912
944
|
|
|
913
945
|
## onEnd Hook
|
|
914
946
|
The `onEnd` function will be executed after report generated. Arguments:
|
|
@@ -948,39 +980,39 @@ module.exports = {
|
|
|
948
980
|
```
|
|
949
981
|
## Send Email
|
|
950
982
|
- Simply send email with [nodemailer](https://nodemailer.com)
|
|
951
|
-
- Example: [send-email](https://github.com/cenfun/monocart-reporter-
|
|
983
|
+
- Example: [send-email](https://github.com/cenfun/monocart-reporter-examples/tree/main/integrations/send-email)
|
|
952
984
|
|
|
953
985
|
## Testrail Integration
|
|
954
986
|
- Send test results to your [Testrail](https://www.testrail.com/)
|
|
955
|
-
- Example: [testrail](https://github.com/cenfun/monocart-reporter-
|
|
987
|
+
- Example: [testrail](https://github.com/cenfun/monocart-reporter-examples/tree/main/integrations/testrail)
|
|
956
988
|
|
|
957
989
|
## Jira + Zephyr Scale Integration
|
|
958
990
|
- Create test cycle and executions with [zephyr-scale-api](https://support.smartbear.com/zephyr-scale-cloud/api-docs/)
|
|
959
|
-
- Example: [zephyr-scale](https://github.com/cenfun/monocart-reporter-
|
|
991
|
+
- Example: [zephyr-scale](https://github.com/cenfun/monocart-reporter-examples/tree/main/integrations/zephyr-scale)
|
|
960
992
|
|
|
961
993
|
## Jira + Xray Integration
|
|
962
994
|
- Import test execution results with [Xray REST API](https://docs.getxray.app/display/XRAYCLOUD/REST+API)
|
|
963
995
|
- Update Jira issue status with [Jira Transition API](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-transitions-post)
|
|
964
|
-
- Example: [xray](https://github.com/cenfun/monocart-reporter-
|
|
996
|
+
- Example: [xray](https://github.com/cenfun/monocart-reporter-examples/tree/main/integrations/xray)
|
|
965
997
|
|
|
966
998
|
## Slack Integration
|
|
967
999
|
- Simply send message with [@slack/webhook](https://github.com/slackapi/node-slack-sdk)
|
|
968
|
-
- Example: [slack-webhook](https://github.com/cenfun/monocart-reporter-
|
|
1000
|
+
- Example: [slack-webhook](https://github.com/cenfun/monocart-reporter-examples/tree/main/integrations/slack-webhook)
|
|
969
1001
|
- Post chat message and upload image with [@slack/web-api](https://github.com/slackapi/node-slack-sdk)
|
|
970
|
-
- Example: [slack-web-api](https://github.com/cenfun/monocart-reporter-
|
|
1002
|
+
- Example: [slack-web-api](https://github.com/cenfun/monocart-reporter-examples/tree/main/integrations/slack-web-api)
|
|
971
1003
|
|
|
972
1004
|
## Discord Integration
|
|
973
1005
|
- Using [Discord webhooks](https://discord.com/developers/docs/resources/webhook) to post messages to channels.
|
|
974
|
-
- Example: [discord-webhook](https://github.com/cenfun/monocart-reporter-
|
|
1006
|
+
- Example: [discord-webhook](https://github.com/cenfun/monocart-reporter-examples/tree/main/integrations/discord-webhook)
|
|
975
1007
|
|
|
976
1008
|
## Teams Integration
|
|
977
1009
|
- Please create an [Incoming Webhooks](https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook) for the channel first.
|
|
978
|
-
- Example: [teams-webhook](https://github.com/cenfun/monocart-reporter-
|
|
1010
|
+
- Example: [teams-webhook](https://github.com/cenfun/monocart-reporter-examples/tree/main/integrations/teams-webhook)
|
|
979
1011
|
|
|
980
1012
|
## Dingtalk/Weixin/Feishu Integration
|
|
981
|
-
- [dingtalk-webhook](https://github.com/cenfun/monocart-reporter-
|
|
982
|
-
- [weixin-webhook](https://github.com/cenfun/monocart-reporter-
|
|
983
|
-
- [feishu-webhook](https://github.com/cenfun/monocart-reporter-
|
|
1013
|
+
- [dingtalk-webhook](https://github.com/cenfun/monocart-reporter-examples/tree/main/integrations/dingtalk-webhook)
|
|
1014
|
+
- [weixin-webhook](https://github.com/cenfun/monocart-reporter-examples/tree/main/integrations/weixin-webhook)
|
|
1015
|
+
- [feishu-webhook](https://github.com/cenfun/monocart-reporter-examples/tree/main/integrations/feishu-webhook)
|
|
984
1016
|
|
|
985
1017
|
|
|
986
1018
|
## Contributing
|
package/lib/plugins/comments.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "monocart-reporter",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "A playwright test reporter. Shows suites/cases/steps with tree style, markdown annotations, custom columns/formatters/data collection visitors, console logs, style tags, send email.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
"koa": "~2.15.0",
|
|
48
48
|
"koa-static-resolver": "~1.0.4",
|
|
49
49
|
"lz-utils": "~2.0.1",
|
|
50
|
-
"monocart-coverage-reports": "~2.0.
|
|
51
|
-
"monocart-formatter": "
|
|
50
|
+
"monocart-coverage-reports": "~2.0.10",
|
|
51
|
+
"monocart-formatter": "~2.3.0",
|
|
52
52
|
"nodemailer": "~6.9.8",
|
|
53
|
-
"open": "~10.0.
|
|
54
|
-
"turbogrid": "
|
|
53
|
+
"open": "~10.0.3",
|
|
54
|
+
"turbogrid": "~3.0.12"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@playwright/test": "^1.40.1",
|