html-reporter 9.2.2 → 9.3.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ <a name="9.3.0"></a>
6
+ # [9.3.0](https://github.com/gemini-testing/html-reporter/compare/v9.2.2...v9.3.0) (2022-09-15)
7
+
8
+
9
+ ### Features
10
+
11
+ * add REPORT_SAVED event ([cd16aa6](https://github.com/gemini-testing/html-reporter/commit/cd16aa6))
12
+ * use EventEmitter2 instead of AsyncEmitter from gemini-core ([3c41ab7](https://github.com/gemini-testing/html-reporter/commit/3c41ab7))
13
+
14
+
15
+
5
16
  <a name="9.2.2"></a>
6
17
  ## [9.2.2](https://github.com/gemini-testing/html-reporter/compare/v9.2.1...v9.2.2) (2022-08-23)
7
18
 
package/README.md CHANGED
@@ -534,7 +534,8 @@ Property name | Description
534
534
  Event | Description
535
535
  ------------------------- | -------------
536
536
  `DATABASE_CREATED` | Will be triggered after sqlite database is created. The handler accepts a database instance. The event is synchronous.
537
- `TEST_SCREENSHOTS_SAVED` | Will be triggered after test screenshots were saved. The handler accepts test id and screenshots info. The event is synchronous.
537
+ `TEST_SCREENSHOTS_SAVED` | Will be triggered after test screenshots were saved. The handler accepts test id and screenshots info. The event is asynchronous, so your handler can return a promise.
538
+ `REPORT_SAVED` | Will be triggered after all test files were saved. The event is asynchronous, so your handler can return a promise.
538
539
 
539
540
  ### events
540
541
 
@@ -558,7 +559,7 @@ module.exports = (hermione, opts) => {
558
559
  Example of a subscription to an event `TEST_SCREENSHOTS_SAVED`:
559
560
 
560
561
  ```js
561
- hermione.htmlReporter.on(hermione.htmlReporter.events.TEST_SCREENSHOTS_SAVED, ({testId, attempt, imagesInfo}) => {
562
+ hermione.htmlReporter.on(hermione.htmlReporter.events.TEST_SCREENSHOTS_SAVED, async ({testId, attempt, imagesInfo}) => {
562
563
  console.log(`Screenshots for test "${testId}" (attempt #${attempt}) were saved:`, imagesInfo);
563
564
  /* Expected output:
564
565
  Screenshots for test "Feature Test.chrome-desktop" (attempt #0) were saved:
@@ -578,6 +579,13 @@ hermione.htmlReporter.on(hermione.htmlReporter.events.TEST_SCREENSHOTS_SAVED, ({
578
579
  });
579
580
  ```
580
581
 
582
+ Example of a subscription to an event `REPORT_SAVED`:
583
+ ```js
584
+ hermione.htmlReporter.on(hermione.htmlReporter.events.REPORT_SAVED, async ({reportPath}) => {
585
+ await uploadDirToS3(reportPath);
586
+ });
587
+ ```
588
+
581
589
  ### addExtraItem
582
590
 
583
591
  Adds item to html report as link:
@@ -2,7 +2,8 @@
2
2
 
3
3
  const getSyncEvents = () => ({
4
4
  DATABASE_CREATED: 'databaseCreated',
5
- TEST_SCREENSHOTS_SAVED: 'testScreenshotsSaved'
5
+ TEST_SCREENSHOTS_SAVED: 'testScreenshotsSaved',
6
+ REPORT_SAVED: 'reportSaved'
6
7
  });
7
8
 
8
9
  const events = getSyncEvents();
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- const {AsyncEmitter} = require('gemini-core').events;
3
+ const EventEmitter2 = require('eventemitter2');
4
4
  const guiEvents = require('../constants/gui-events');
5
5
 
6
- module.exports = class ApiFacade extends AsyncEmitter {
6
+ module.exports = class ApiFacade extends EventEmitter2 {
7
7
  static create() {
8
8
  return new ApiFacade();
9
9
  }
@@ -12,10 +12,10 @@ module.exports = class Api {
12
12
  }
13
13
 
14
14
  async initServer(server) {
15
- await this._gui.emitAndWait(this._gui.events.SERVER_INIT, server);
15
+ await this._gui.emitAsync(this._gui.events.SERVER_INIT, server);
16
16
  }
17
17
 
18
18
  async serverReady(data) {
19
- await this._gui.emitAndWait(this._gui.events.SERVER_READY, data);
19
+ await this._gui.emitAsync(this._gui.events.SERVER_READY, data);
20
20
  }
21
21
  };
@@ -9,6 +9,8 @@ module.exports = async (pluginConfig, hermione, srcPaths, {destination: destPath
9
9
  serverUtils.saveStaticFilesToReportDir(hermione, pluginConfig, destPath),
10
10
  serverUtils.writeDatabaseUrlsFile(destPath, srcPaths)
11
11
  ]);
12
+
13
+ await hermione.htmlReporter.emitAsync(hermione.htmlReporter.events.REPORT_SAVED, {reportPath: destPath});
12
14
  };
13
15
 
14
16
  function validateOpts(srcPaths, destPath) {
@@ -55,7 +55,12 @@ module.exports = class PluginAdapter {
55
55
  staticReportBuilder.saveStaticFiles(),
56
56
  prepareData(this._hermione, staticReportBuilder, this._config)
57
57
  ])
58
- .then(() => staticReportBuilder.finalize());
58
+ .then(() => staticReportBuilder.finalize())
59
+ .then(async () => {
60
+ const htmlReporter = this._hermione.htmlReporter;
61
+
62
+ await htmlReporter.emitAsync(htmlReporter.events.REPORT_SAVED, {reportPath: this._config.path});
63
+ });
59
64
  }
60
65
 
61
66
  async _run(prepareData) {
package/lib/plugin-api.js CHANGED
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- const AsyncEmitter = require('gemini-core').events.AsyncEmitter;
3
+ const EventsEmitter2 = require('eventemitter2');
4
4
  const pluginEvents = require('./constants/plugin-events');
5
5
  const {downloadDatabases, mergeDatabases, getTestsTreeFromDatabase} = require('./db-utils/server');
6
6
 
7
- module.exports = class HtmlReporter extends AsyncEmitter {
7
+ module.exports = class HtmlReporter extends EventsEmitter2 {
8
8
  static create(config) {
9
9
  return new this(config);
10
10
  }
@@ -368,7 +368,7 @@ module.exports = class TestAdapter {
368
368
  }
369
369
 
370
370
  const htmlReporter = this._hermione.htmlReporter;
371
- htmlReporter.emit(htmlReporter.events.TEST_SCREENSHOTS_SAVED, {
371
+ await htmlReporter.emitAsync(htmlReporter.events.TEST_SCREENSHOTS_SAVED, {
372
372
  testId: this._testId,
373
373
  attempt: this.attempt,
374
374
  imagesInfo: this.getImagesInfo()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "html-reporter",
3
- "version": "9.2.2",
3
+ "version": "9.3.0",
4
4
  "description": "Plugin for hermione which is intended to aggregate the results of tests running into html report",
5
5
  "scripts": {
6
6
  "coverage": "nyc npm run test-unit",
@@ -50,6 +50,7 @@
50
50
  "body-parser": "^1.18.2",
51
51
  "chalk": "^1.1.3",
52
52
  "debug": "^4.1.1",
53
+ "eventemitter2": "6.4.7",
53
54
  "express": "^4.16.2",
54
55
  "filesize": "^8.0.6",
55
56
  "fs-extra": "^7.0.1",