@allurereport/plugin-log 3.17.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` |
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` |
54
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,7 +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";
7
+ qualityGateResults?: boolean;
8
+ qualityGateFilter?: (result: QualityGateValidationResult) => boolean;
6
9
  filter?: (testResult: TestResult) => boolean;
7
10
  };
package/dist/plugin.js CHANGED
@@ -1,42 +1,49 @@
1
1
  import * as console from "node:console";
2
2
  import { gray } from "yoctocolors";
3
- import { printSummary, printTest } from "./utils.js";
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 } = 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);
12
+ const qualityGateResultsToPrint = qualityGateResults
13
+ ? (await store.qualityGateResults()).filter(qualityGateFilter)
14
+ : [];
11
15
  if (groupBy === "none") {
12
16
  filteredTestResults.forEach((test) => {
13
17
  printTest(test, this.options);
14
18
  });
15
19
  console.log("");
16
- printSummary(filteredTestResults, { total: allTestResults.length, filtered: filteredTestResults.length });
17
- return;
18
20
  }
19
- const groupedTests = await store.testResultsByLabel(groupBy);
20
- Object.keys(groupedTests).forEach((key) => {
21
- const tests = groupedTests[key].filter(filter);
22
- if (tests.length === 0) {
23
- return;
24
- }
25
- if (key === "_") {
26
- console.info(gray("uncategorized"));
27
- }
28
- else {
29
- console.info(key);
30
- }
31
- tests.forEach((test) => {
32
- printTest(test, this.options, 1);
21
+ else {
22
+ const groupedTests = await store.testResultsByLabel(groupBy);
23
+ Object.keys(groupedTests).forEach((key) => {
24
+ const tests = groupedTests[key].filter(filter);
25
+ if (tests.length === 0) {
26
+ return;
27
+ }
28
+ if (key === "_") {
29
+ console.info(gray("uncategorized"));
30
+ }
31
+ else {
32
+ console.info(key);
33
+ }
34
+ tests.forEach((test) => {
35
+ printTest(test, this.options, 1);
36
+ });
37
+ console.log("");
33
38
  });
34
- console.log("");
35
- });
39
+ }
36
40
  printSummary(filteredTestResults, {
37
41
  total: allTestResults.length,
38
42
  filtered: filteredTestResults.length,
39
43
  });
44
+ if (qualityGateResults) {
45
+ printQualityGateResults(qualityGateResultsToPrint);
46
+ }
40
47
  };
41
48
  }
42
49
  }
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { DefaultTestStepResult, TestResult, TestStatus, TestStepResult } from "@allurereport/core-api";
2
+ import type { QualityGateValidationResult } from "@allurereport/plugin-api";
2
3
  import type { LogPluginOptions } from "./model.js";
3
4
  export type PrintFunctionOptions = Pick<LogPluginOptions, "allSteps" | "groupBy" | "withTrace">;
4
5
  export declare const isFailedResult: (result: TestResult | TestStepResult) => boolean;
@@ -6,9 +7,12 @@ export declare const hasResultFailedSteps: (result: TestResult | TestStepResult)
6
7
  export declare const stringifyStatusBadge: (status: TestStatus) => string;
7
8
  export declare const stringifyTestResultTitle: (result: TestResult) => string;
8
9
  export declare const stringifyStepResultTitle: (result: DefaultTestStepResult) => string;
10
+ export declare const stringifyQualityGateResultTitle: (result: QualityGateValidationResult) => string;
9
11
  export declare const printTest: (test: TestResult, options?: PrintFunctionOptions, indent?: number) => void;
10
12
  export declare const printStep: (step: DefaultTestStepResult, options?: PrintFunctionOptions, indent?: number) => void;
11
13
  export declare const printSummary: (results: TestResult[], options: {
12
14
  total: number;
13
15
  filtered: number;
14
16
  }) => void;
17
+ export declare const printQualityGateResult: (result: QualityGateValidationResult, indent?: number) => void;
18
+ export declare const printQualityGateResults: (results: QualityGateValidationResult[]) => void;
package/dist/utils.js CHANGED
@@ -46,6 +46,11 @@ export const stringifyStepResultTitle = (result) => {
46
46
  const duration = result.duration ? `${yellow(`${result.duration}ms`)}` : "";
47
47
  return [status, result.name, duration].filter(Boolean).join(" ");
48
48
  };
49
+ export const stringifyQualityGateResultTitle = (result) => {
50
+ const status = result.success ? green("✓") : red("⨯");
51
+ const environment = result.environment ? gray(`[${result.environment}]`) : "";
52
+ return [status, result.rule, environment].filter(Boolean).join(" ");
53
+ };
49
54
  export const printTest = (test, options, indent = 0) => {
50
55
  const title = stringifyTestResultTitle(test);
51
56
  const stepsToPrint = options?.allSteps ? test.steps.filter(isStep) : test.steps.filter(isFailedResult).filter(isStep);
@@ -140,3 +145,30 @@ export const printSummary = (results, options) => {
140
145
  console.info(`Tests: ${stringifiedCounters.join(" | ")}`);
141
146
  console.info(`Duration: ${yellow((totalDuration / 1000).toString())}s`);
142
147
  };
148
+ export const printQualityGateResult = (result, indent = 0) => {
149
+ const indentSpaces = " ".repeat(indent);
150
+ const message = result.success ? green(result.message) : red(result.message);
151
+ console.info(`${indentSpaces}${stringifyQualityGateResultTitle(result)}`);
152
+ console.info(`${indentSpaces} ${message}`);
153
+ };
154
+ export const printQualityGateResults = (results) => {
155
+ if (results.length === 0) {
156
+ return;
157
+ }
158
+ console.log("");
159
+ console.info("Quality gates");
160
+ const orderedResults = [...results.filter(({ success }) => !success), ...results.filter(({ success }) => success)];
161
+ orderedResults.forEach((result) => {
162
+ printQualityGateResult(result, 1);
163
+ });
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(" | ")}`);
174
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/plugin-log",
3
- "version": "3.17.0",
3
+ "version": "3.19.0",
4
4
  "description": "Allure Plugin to write report in stdout",
5
5
  "keywords": [
6
6
  "allure",
@@ -31,9 +31,9 @@
31
31
  "lint:fix": "oxlint --import-plugin --fix src test features stories"
32
32
  },
33
33
  "dependencies": {
34
- "@allurereport/core-api": "3.17.0",
35
- "@allurereport/plugin-api": "3.17.0",
36
- "yoctocolors": "^2.1.2"
34
+ "@allurereport/core-api": "3.19.0",
35
+ "@allurereport/plugin-api": "3.19.0",
36
+ "yoctocolors": "^2.2.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/node": "^20",