@cucumber/html-formatter 22.3.0 → 23.1.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.
Files changed (79) hide show
  1. package/.mocharc.json +3 -9
  2. package/biome.json +4 -0
  3. package/dist/main.css +13 -9
  4. package/dist/main.js +1 -1
  5. package/dist/main.js.LICENSE.txt +20 -23
  6. package/dist/package.json +29 -40
  7. package/dist/src/CucumberHtmlStream.d.ts +3 -3
  8. package/dist/src/CucumberHtmlStream.d.ts.map +1 -1
  9. package/dist/src/CucumberHtmlStream.js +14 -11
  10. package/dist/src/CucumberHtmlStream.js.map +1 -1
  11. package/dist/src/CucumberHtmlStream.spec.js +7 -7
  12. package/dist/src/CucumberHtmlStream.spec.js.map +1 -1
  13. package/dist/src/main.d.ts +1 -1
  14. package/dist/src/main.d.ts.map +1 -1
  15. package/dist/src/main.js +2 -8
  16. package/dist/src/main.js.map +1 -1
  17. package/dist/test/acceptance.spec.js +2 -2
  18. package/dist/test/acceptance.spec.js.map +1 -1
  19. package/dist/tsconfig.build.tsbuildinfo +1 -1
  20. package/docker-compose.yml +1 -1
  21. package/package.json +29 -40
  22. package/playwright.config.ts +4 -4
  23. package/src/CucumberHtmlStream.spec.ts +11 -23
  24. package/src/CucumberHtmlStream.ts +28 -44
  25. package/src/main.tsx +2 -7
  26. package/test/__screenshots__/all-statuses.png +0 -0
  27. package/test/__screenshots__/ambiguous.png +0 -0
  28. package/test/__screenshots__/attachments.png +0 -0
  29. package/test/__screenshots__/backgrounds.png +0 -0
  30. package/test/__screenshots__/cdata.png +0 -0
  31. package/test/__screenshots__/data-tables.png +0 -0
  32. package/test/__screenshots__/doc-strings.png +0 -0
  33. package/test/__screenshots__/empty.png +0 -0
  34. package/test/__screenshots__/examples-tables-attachment.png +0 -0
  35. package/test/__screenshots__/examples-tables-undefined.png +0 -0
  36. package/test/__screenshots__/examples-tables.png +0 -0
  37. package/test/__screenshots__/failedish-combinations.png +0 -0
  38. package/test/__screenshots__/global-hooks-afterall-error.png +0 -0
  39. package/test/__screenshots__/global-hooks-attachments.png +0 -0
  40. package/test/__screenshots__/global-hooks-beforeall-error.png +0 -0
  41. package/test/__screenshots__/global-hooks.png +0 -0
  42. package/test/__screenshots__/hooks-attachment.png +0 -0
  43. package/test/__screenshots__/hooks-conditional.png +0 -0
  44. package/test/__screenshots__/hooks-named.png +0 -0
  45. package/test/__screenshots__/hooks-skipped.png +0 -0
  46. package/test/__screenshots__/hooks-undefined.png +0 -0
  47. package/test/__screenshots__/hooks.png +0 -0
  48. package/test/__screenshots__/markdown.png +0 -0
  49. package/test/__screenshots__/minimal.png +0 -0
  50. package/test/__screenshots__/multiple-features-reversed.png +0 -0
  51. package/test/__screenshots__/multiple-features.png +0 -0
  52. package/test/__screenshots__/parameter-types.png +0 -0
  53. package/test/__screenshots__/pending-exception.png +0 -0
  54. package/test/__screenshots__/pending.png +0 -0
  55. package/test/__screenshots__/regular-expression.png +0 -0
  56. package/test/__screenshots__/retry-ambiguous.png +0 -0
  57. package/test/__screenshots__/retry-pending.png +0 -0
  58. package/test/__screenshots__/retry-undefined.png +0 -0
  59. package/test/__screenshots__/retry.png +0 -0
  60. package/test/__screenshots__/rules-backgrounds.png +0 -0
  61. package/test/__screenshots__/rules.png +0 -0
  62. package/test/__screenshots__/skipped-exception.png +0 -0
  63. package/test/__screenshots__/skipped-failing-hook.png +0 -0
  64. package/test/__screenshots__/skipped.png +0 -0
  65. package/test/__screenshots__/stack-traces.png +0 -0
  66. package/test/__screenshots__/test-run-exception.png +0 -0
  67. package/test/__screenshots__/undefined.png +0 -0
  68. package/test/__screenshots__/unknown-parameter-type.png +0 -0
  69. package/test/__screenshots__/unused-steps.png +0 -0
  70. package/test/acceptance.spec.ts +3 -5
  71. package/test/screenshot.css +2 -2
  72. package/tsconfig.build.json +1 -5
  73. package/tsconfig.json +2 -5
  74. package/webpack.config.js +10 -10
  75. package/.prettierignore +0 -1
  76. package/.prettierrc.json +0 -5
  77. package/eslint.config.mjs +0 -78
  78. /package/dist/src/{index.mustache.html → index.mustache} +0 -0
  79. /package/src/{index.mustache.html → index.mustache} +0 -0
@@ -1,7 +1,7 @@
1
- import * as messages from '@cucumber/messages'
2
- import fs from 'fs'
3
- import path from 'path'
4
- import { Readable, Transform, TransformCallback } from 'stream'
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+ import { type Readable, Transform, type TransformCallback } from 'node:stream'
4
+ import type { Envelope } from '@cucumber/messages'
5
5
 
6
6
  export class CucumberHtmlStream extends Transform {
7
7
  private template: string | null = null
@@ -22,17 +22,17 @@ export class CucumberHtmlStream extends Transform {
22
22
  super({ objectMode: true })
23
23
  }
24
24
 
25
- public _transform(
26
- envelope: messages.Envelope,
27
- encoding: string,
28
- callback: TransformCallback
29
- ): void {
25
+ public _transform(envelope: Envelope, _encoding: string, callback: TransformCallback): void {
30
26
  if (this.postMessageWritten) {
31
- return callback(new Error('Stream closed'))
27
+ callback(new Error('Stream closed'))
28
+ return
32
29
  }
33
30
 
34
31
  this.writePreMessageUnlessAlreadyWritten((err) => {
35
- if (err) return callback(err)
32
+ if (err) {
33
+ callback(err)
34
+ return
35
+ }
36
36
  this.writeMessage(envelope)
37
37
  callback()
38
38
  })
@@ -60,14 +60,10 @@ export class CucumberHtmlStream extends Transform {
60
60
  if (err) return callback(err)
61
61
  this.writeTemplateBetween('{{css}}', '{{custom_css}}', (err) => {
62
62
  if (err) return callback(err)
63
- this.writeTemplateBetween(
64
- '{{custom_css}}',
65
- '{{messages}}',
66
- (err) => {
67
- if (err) return callback(err)
68
- callback()
69
- }
70
- )
63
+ this.writeTemplateBetween('{{custom_css}}', '{{messages}}', (err) => {
64
+ if (err) return callback(err)
65
+ callback()
66
+ })
71
67
  })
72
68
  })
73
69
  })
@@ -83,14 +79,10 @@ export class CucumberHtmlStream extends Transform {
83
79
  if (err) return callback(err)
84
80
  this.writeFile(this.jsPath, (err) => {
85
81
  if (err) return callback(err)
86
- this.writeTemplateBetween(
87
- '{{script}}',
88
- '{{custom_script}}',
89
- (err) => {
90
- if (err) return callback(err)
91
- this.writeTemplateBetween('{{custom_script}}', null, callback)
92
- }
93
- )
82
+ this.writeTemplateBetween('{{script}}', '{{custom_script}}', (err) => {
83
+ if (err) return callback(err)
84
+ this.writeTemplateBetween('{{custom_script}}', null, callback)
85
+ })
94
86
  })
95
87
  })
96
88
  })
@@ -110,34 +102,26 @@ export class CucumberHtmlStream extends Transform {
110
102
  ) {
111
103
  this.readTemplate((err, template) => {
112
104
  if (err) return callback(err)
113
- if (!template)
114
- return callback(new Error('template is required if error is missing'))
115
- const beginIndex =
116
- begin == null ? 0 : template.indexOf(begin) + begin.length
105
+ if (!template) return callback(new Error('template is required if error is missing'))
106
+ const beginIndex = begin == null ? 0 : template.indexOf(begin) + begin.length
117
107
  const endIndex = end == null ? template.length : template.indexOf(end)
118
108
  this.push(template.substring(beginIndex, endIndex))
119
109
  callback()
120
110
  })
121
111
  }
122
112
 
123
- private readTemplate(
124
- callback: (error?: Error | null, data?: string) => void
125
- ) {
113
+ private readTemplate(callback: (error?: Error | null, data?: string) => void) {
126
114
  if (this.template !== null) {
127
115
  return callback(null, this.template)
128
116
  }
129
- fs.readFile(
130
- __dirname + '/index.mustache.html',
131
- { encoding: 'utf-8' },
132
- (err, template) => {
133
- if (err) return callback(err)
134
- this.template = template
135
- return callback(null, template)
136
- }
137
- )
117
+ fs.readFile(`${__dirname}/index.mustache`, { encoding: 'utf-8' }, (err, template) => {
118
+ if (err) return callback(err)
119
+ this.template = template
120
+ return callback(null, template)
121
+ })
138
122
  }
139
123
 
140
- private writeMessage(envelope: messages.Envelope) {
124
+ private writeMessage(envelope: Envelope) {
141
125
  if (!this.firstMessageWritten) {
142
126
  this.firstMessageWritten = true
143
127
  } else {
package/src/main.tsx CHANGED
@@ -1,12 +1,7 @@
1
1
  import './styles.scss'
2
2
 
3
- import { Envelope } from '@cucumber/messages'
4
- import {
5
- EnvelopesProvider,
6
- Report,
7
- UrlSearchProvider,
8
- } from '@cucumber/react-components'
9
- import React from 'react'
3
+ import type { Envelope } from '@cucumber/messages'
4
+ import { EnvelopesProvider, Report, UrlSearchProvider } from '@cucumber/react-components'
10
5
  import { createRoot } from 'react-dom/client'
11
6
 
12
7
  declare global {
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -8,16 +8,14 @@ import { sync } from 'glob'
8
8
 
9
9
  import { CucumberHtmlStream } from '../src'
10
10
 
11
- const fixtures = sync(
12
- `./node_modules/@cucumber/compatibility-kit/features/**/*.ndjson`
13
- )
11
+ const fixtures = sync(`./node_modules/@cucumber/compatibility-kit/features/**/*.ndjson`)
14
12
 
15
13
  test.beforeAll(async () => {
16
14
  const outputDir = path.join(__dirname, './__output__')
17
15
 
18
16
  for (const fixture of fixtures) {
19
17
  const name = path.basename(fixture, '.ndjson')
20
- const outputFile = path.join(outputDir, name + '.html')
18
+ const outputFile = path.join(outputDir, `${name}.html`)
21
19
 
22
20
  await pipeline(
23
21
  fs.createReadStream(fixture, { encoding: 'utf-8' }),
@@ -38,6 +36,6 @@ for (const fixture of fixtures) {
38
36
  test(`can render ${name}`, async ({ page }) => {
39
37
  await page.goto(`/${name}.html`)
40
38
  await page.waitForSelector('#report', { timeout: 3000 })
41
- await expect(page).toHaveScreenshot(`${name}.png`)
39
+ await expect(page).toHaveScreenshot(`${name}.png`, { fullPage: true })
42
40
  })
43
41
  }
@@ -1,4 +1,4 @@
1
1
  time,
2
- [data-testid='cucumber.summary.setup'] {
3
- visibility: hidden !important;
2
+ [data-testid="cucumber.summary.setup"] {
3
+ visibility: hidden;
4
4
  }
@@ -7,9 +7,5 @@
7
7
  "declarationMap": true,
8
8
  "noEmit": false
9
9
  },
10
- "include": [
11
- "src",
12
- "test",
13
- "package.json"
14
- ]
10
+ "include": ["src", "test", "package.json"]
15
11
  }
package/tsconfig.json CHANGED
@@ -12,14 +12,11 @@
12
12
  "strictNullChecks": true,
13
13
  "experimentalDecorators": true,
14
14
  "module": "CommonJS",
15
- "lib": [
16
- "ES6",
17
- "dom"
18
- ],
15
+ "lib": ["ES6", "dom"],
19
16
  "target": "ES6",
20
17
  "moduleResolution": "node",
21
18
  "allowSyntheticDefaultImports": true,
22
19
  "noEmit": true,
23
- "jsx": "react"
20
+ "jsx": "react-jsx"
24
21
  }
25
22
  }
package/webpack.config.js CHANGED
@@ -1,4 +1,4 @@
1
- const MiniCssExtractPlugin = require('mini-css-extract-plugin');
1
+ const MiniCssExtractPlugin = require('mini-css-extract-plugin')
2
2
 
3
3
  module.exports = {
4
4
  entry: './dist/src/main.js',
@@ -13,18 +13,18 @@ module.exports = {
13
13
  options: {
14
14
  modules: {
15
15
  auto: true,
16
- namedExport: false
17
- }
18
- }
16
+ namedExport: false,
17
+ },
18
+ },
19
19
  },
20
- 'sass-loader'
20
+ 'sass-loader',
21
21
  ],
22
- }
22
+ },
23
23
  ],
24
24
  },
25
25
  plugins: [
26
26
  new MiniCssExtractPlugin({
27
- filename: 'main.css'
28
- })
29
- ]
30
- };
27
+ filename: 'main.css',
28
+ }),
29
+ ],
30
+ }
package/.prettierignore DELETED
@@ -1 +0,0 @@
1
- *.html
package/.prettierrc.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "trailingComma": "es5",
3
- "singleQuote": true,
4
- "semi": false
5
- }
package/eslint.config.mjs DELETED
@@ -1,78 +0,0 @@
1
- import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
2
- import react from "eslint-plugin-react";
3
- import _import from "eslint-plugin-import";
4
- import simpleImportSort from "eslint-plugin-simple-import-sort";
5
- import n from "eslint-plugin-n";
6
- import typescriptEslint from "@typescript-eslint/eslint-plugin";
7
- import globals from "globals";
8
- import tsParser from "@typescript-eslint/parser";
9
- import path from "node:path";
10
- import { fileURLToPath } from "node:url";
11
- import js from "@eslint/js";
12
- import { FlatCompat } from "@eslint/eslintrc";
13
-
14
- const __filename = fileURLToPath(import.meta.url);
15
- const __dirname = path.dirname(__filename);
16
- const compat = new FlatCompat({
17
- baseDirectory: __dirname,
18
- recommendedConfig: js.configs.recommended,
19
- allConfig: js.configs.all
20
- });
21
-
22
- export default [...fixupConfigRules(compat.extends(
23
- "eslint:recommended",
24
- "plugin:react/recommended",
25
- "plugin:react-hooks/recommended",
26
- "plugin:import/typescript",
27
- "plugin:@typescript-eslint/eslint-recommended",
28
- "plugin:@typescript-eslint/recommended",
29
- )), {
30
- plugins: {
31
- react: fixupPluginRules(react),
32
- import: fixupPluginRules(_import),
33
- "simple-import-sort": simpleImportSort,
34
- n,
35
- "@typescript-eslint": fixupPluginRules(typescriptEslint),
36
- },
37
-
38
- languageOptions: {
39
- globals: {
40
- ...globals.browser,
41
- ...globals.node,
42
- },
43
-
44
- parser: tsParser,
45
- ecmaVersion: 5,
46
- sourceType: "module",
47
- },
48
-
49
- settings: {
50
- react: {
51
- pragma: "React",
52
- version: "detect",
53
- },
54
- },
55
-
56
- rules: {
57
- "import/no-cycle": "error",
58
- "n/no-extraneous-import": "error",
59
- "@typescript-eslint/ban-ts-ignore": "off",
60
- "@typescript-eslint/ban-ts-comment": "off",
61
- "@typescript-eslint/explicit-module-boundary-types": "off",
62
- "@typescript-eslint/explicit-function-return-type": "off",
63
- "@typescript-eslint/no-use-before-define": "off",
64
- "@typescript-eslint/interface-name-prefix": "off",
65
- "@typescript-eslint/member-delimiter-style": "off",
66
- "@typescript-eslint/no-explicit-any": "error",
67
- "@typescript-eslint/no-non-null-assertion": "error",
68
- "simple-import-sort/imports": "error",
69
- "simple-import-sort/exports": "error",
70
- "react/prop-types": "off",
71
- },
72
- }, {
73
- files: ["test/**"],
74
-
75
- rules: {
76
- "@typescript-eslint/no-non-null-assertion": "off",
77
- },
78
- }];
File without changes