@allurereport/plugin-log 3.18.0 → 3.19.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/README.md CHANGED
@@ -46,9 +46,28 @@ export default defineConfig({
46
46
 
47
47
  The plugin accepts the following options:
48
48
 
49
- | Option | Description | Type | Default |
50
- |----------------------|--------------------------------------------------|------------------------------------------|---------|
51
- | `allSteps` | Include all steps in the report | `boolean` | `false` |
52
- | `withTrace` | Include step trace in the report | `boolean` | `false` |
53
- | `groupBy` | Group tests by given label | `suites \| features \| packages \| none` | `none` |
54
- | `qualityGateResults` | Include quality gate validation results in logs | `boolean` | `true` |
49
+ | Option | Description | Type | Default |
50
+ |----------------------|-------------------------------------------------------|-----------------------------------------------------|---------------------------------|
51
+ | `allSteps` | Include all steps in the report | `boolean` | `false` |
52
+ | `withTrace` | Include step trace in the report | `boolean` | `false` |
53
+ | `groupBy` | Group tests by given label | `suite \| feature \| package \| suites \| features \| packages \| none` | `suite` |
54
+ | `qualityGateResults` | Include quality gate validation results in logs | `boolean` | `true` |
55
+ | `qualityGateFilter` | Select quality gate validation results shown in logs | `(result: QualityGateValidationResult) => boolean` | `({ success }) => !success` |
56
+
57
+ To show both successful and failed quality gate checks, configure the filter to include every result:
58
+
59
+ ```js
60
+ export default {
61
+ plugins: {
62
+ log: {
63
+ options: {
64
+ qualityGateFilter: () => true,
65
+ },
66
+ },
67
+ },
68
+ };
69
+ ```
70
+
71
+ For `allure log`, use the `--all-quality-gate-results` flag to include successful quality gate checks. The command
72
+ constructs its own log plugin configuration for that run, so plugin configuration from the Allure config file is not
73
+ applied to `allure log`.
package/dist/model.d.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  import type { TestResult } from "@allurereport/core-api";
2
+ import type { QualityGateValidationResult } from "@allurereport/plugin-api";
2
3
  export type LogPluginOptions = {
3
4
  allSteps?: boolean;
4
5
  withTrace?: boolean;
5
- groupBy?: "suites" | "features" | "packages" | "none";
6
+ groupBy?: "suite" | "feature" | "package" | "suites" | "features" | "packages" | "none";
6
7
  qualityGateResults?: boolean;
8
+ qualityGateFilter?: (result: QualityGateValidationResult) => boolean;
7
9
  filter?: (testResult: TestResult) => boolean;
8
10
  };
package/dist/plugin.js CHANGED
@@ -1,14 +1,17 @@
1
1
  import * as console from "node:console";
2
2
  import { gray } from "yoctocolors";
3
3
  import { printQualityGateResults, printSummary, printTest } from "./utils.js";
4
+ const defaultQualityGateFilter = ({ success }) => !success;
4
5
  export class LogPlugin {
5
6
  constructor(options = {}) {
6
7
  this.options = options;
7
8
  this.done = async (context, store) => {
8
- const { groupBy = "suite", filter = () => true, qualityGateResults = true } = this.options ?? {};
9
+ const { groupBy = "suite", filter = () => true, qualityGateResults = true, qualityGateFilter = defaultQualityGateFilter, } = this.options ?? {};
9
10
  const allTestResults = await store.allTestResults();
10
11
  const filteredTestResults = allTestResults.filter(filter);
11
- const allQualityGateResults = qualityGateResults ? await store.qualityGateResults() : [];
12
+ const qualityGateResultsToPrint = qualityGateResults
13
+ ? (await store.qualityGateResults()).filter(qualityGateFilter)
14
+ : [];
12
15
  if (groupBy === "none") {
13
16
  filteredTestResults.forEach((test) => {
14
17
  printTest(test, this.options);
@@ -39,7 +42,7 @@ export class LogPlugin {
39
42
  filtered: filteredTestResults.length,
40
43
  });
41
44
  if (qualityGateResults) {
42
- printQualityGateResults(allQualityGateResults);
45
+ printQualityGateResults(qualityGateResultsToPrint);
43
46
  }
44
47
  };
45
48
  }
package/dist/utils.js CHANGED
@@ -147,8 +147,9 @@ export const printSummary = (results, options) => {
147
147
  };
148
148
  export const printQualityGateResult = (result, indent = 0) => {
149
149
  const indentSpaces = " ".repeat(indent);
150
+ const message = result.success ? green(result.message) : red(result.message);
150
151
  console.info(`${indentSpaces}${stringifyQualityGateResultTitle(result)}`);
151
- console.info(`${indentSpaces} ${red(result.message)}`);
152
+ console.info(`${indentSpaces} ${message}`);
152
153
  };
153
154
  export const printQualityGateResults = (results) => {
154
155
  if (results.length === 0) {
@@ -156,9 +157,18 @@ export const printQualityGateResults = (results) => {
156
157
  }
157
158
  console.log("");
158
159
  console.info("Quality gates");
159
- results.forEach((result) => {
160
+ const orderedResults = [...results.filter(({ success }) => !success), ...results.filter(({ success }) => success)];
161
+ orderedResults.forEach((result) => {
160
162
  printQualityGateResult(result, 1);
161
163
  });
162
- const failures = `${results.length} ${results.length === 1 ? "failure" : "failures"}`;
163
- console.info(`Quality gates: ${red(failures)}`);
164
+ const passed = results.filter(({ success }) => success).length;
165
+ const failed = results.length - passed;
166
+ const stats = [];
167
+ if (passed > 0) {
168
+ stats.push(green(`${passed} passed`));
169
+ }
170
+ if (failed > 0) {
171
+ stats.push(red(`${failed} failed`));
172
+ }
173
+ console.info(`Quality gates: ${stats.join(" | ")}`);
164
174
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/plugin-log",
3
- "version": "3.18.0",
3
+ "version": "3.19.0",
4
4
  "description": "Allure Plugin to write report in stdout",
5
5
  "keywords": [
6
6
  "allure",
@@ -31,8 +31,8 @@
31
31
  "lint:fix": "oxlint --import-plugin --fix src test features stories"
32
32
  },
33
33
  "dependencies": {
34
- "@allurereport/core-api": "3.18.0",
35
- "@allurereport/plugin-api": "3.18.0",
34
+ "@allurereport/core-api": "3.19.0",
35
+ "@allurereport/plugin-api": "3.19.0",
36
36
  "yoctocolors": "^2.2.0"
37
37
  },
38
38
  "devDependencies": {