@e2e-dev/html-reporter 0.0.2 → 0.0.3-nightly-20261120030209

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/dist/.build.json CHANGED
@@ -1 +1 @@
1
- {"version":"0.0.2"}
1
+ {"version":"0.0.3-nightly-20261120030209"}
@@ -1,4 +1,4 @@
1
- import type { FinishedRun, Reporter, ReporterSummary } from 'e2e';
1
+ import type { FinishedRun, Reporter, ReportFile } from 'e2e';
2
2
  export interface HtmlReporterOptions {
3
3
  /**
4
4
  * Where the page goes, from the project root. Defaults to `report.html` in
@@ -31,11 +31,8 @@ export interface HtmlReporterOptions {
31
31
  */
32
32
  export declare function htmlReporter(options?: HtmlReporterOptions): Reporter;
33
33
  /**
34
- * Fills the page template with one finished run, writes it, and resolves with
35
- * the row naming where it went. Once `signal` aborts (the runner gave up on
36
- * its reporters), it stops reading files and writes nothing. A run that wrote
37
- * no report (it stopped before its tests, or the write failed) writes no
38
- * page either, so the previous run's page stays beside the previous run's
39
- * report, as `junit.xml` and `summary.md` do.
34
+ * Fills the page template with one finished run: the file the runner writes,
35
+ * with the row naming where it went. Once `signal` aborts (the runner gave up
36
+ * on it), it stops reading files.
40
37
  */
41
- export declare function writeReport(run: FinishedRun, options: HtmlReporterOptions, template: string, signal?: AbortSignal): Promise<ReporterSummary | undefined>;
38
+ export declare function renderReport(run: FinishedRun, options: HtmlReporterOptions, template: string, signal?: AbortSignal): Promise<ReportFile>;
package/dist/reporter.js CHANGED
@@ -1,4 +1,4 @@
1
- import { mkdir, readFile, writeFile } from 'node:fs/promises';
1
+ import { readFile } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
4
  import { embedPayload } from './payload.js';
@@ -20,39 +20,30 @@ const TEMPLATE_PATH = path.join(path.dirname(fileURLToPath(import.meta.url)), 'a
20
20
  export function htmlReporter(options = {}) {
21
21
  return {
22
22
  name: 'html',
23
- onRunFinished: async (run, signal) => writeReport(run, options, await readFile(TEMPLATE_PATH, 'utf8'), signal),
23
+ // A run that wrote no report writes no page, so the previous page stays
24
+ // beside the previous report, as `junit.xml` and `summary.md` do.
25
+ reportFiles: async (run, signal) => run.reportPath === undefined ? [] : [await renderReport(run, options, await readFile(TEMPLATE_PATH, 'utf8'), signal)],
24
26
  };
25
27
  }
26
28
  /**
27
- * Fills the page template with one finished run, writes it, and resolves with
28
- * the row naming where it went. Once `signal` aborts (the runner gave up on
29
- * its reporters), it stops reading files and writes nothing. A run that wrote
30
- * no report (it stopped before its tests, or the write failed) writes no
31
- * page either, so the previous run's page stays beside the previous run's
32
- * report, as `junit.xml` and `summary.md` do.
29
+ * Fills the page template with one finished run: the file the runner writes,
30
+ * with the row naming where it went. Once `signal` aborts (the runner gave up
31
+ * on it), it stops reading files.
33
32
  */
34
- export async function writeReport(run, options, template, signal) {
35
- if (run.reportPath === undefined)
36
- return undefined;
37
- const outputFile = options.outputFile === undefined
38
- ? path.join(path.dirname(run.artifactsRoot), 'report.html')
39
- : path.resolve(run.projectRoot, options.outputFile);
33
+ export async function renderReport(run, options, template, signal) {
34
+ const outputFile = path.resolve(run.projectRoot, options.outputFile ?? path.join(run.outputDir, 'report.html'));
40
35
  const mode = options.media ?? 'link';
41
36
  const media = await pageMedia(mode, run, outputFile, signal);
42
37
  const resultsDir = toPosix(path.relative(run.projectRoot, run.artifactsRoot)) || '.';
43
38
  const traces = Object.fromEntries([...run.traces].map(([id, trace]) => [id, toPosix(trace)]));
44
39
  const sources = await sourceFrames(run.report, run.projectRoot, run.redact);
45
40
  const page = embedPayload(template, { report: run.report, media, resultsDir, traces, sources });
46
- signal?.throwIfAborted();
47
- await mkdir(path.dirname(outputFile), { recursive: true });
48
- await writeFile(outputFile, page, 'utf8');
49
- const shown = path.relative(process.cwd(), outputFile) || outputFile;
50
- let note = '';
41
+ let note;
51
42
  if (mode === 'embed')
52
- note = ` (one file, ${formatSize(Buffer.byteLength(page))})`;
43
+ note = `(one file, ${formatSize(Buffer.byteLength(page))})`;
53
44
  if (mode === 'none')
54
- note = ' (text only)';
55
- return [{ label: 'HTML report', text: `${shown}${note}` }];
45
+ note = '(text only)';
46
+ return { path: outputFile, content: page, label: 'HTML report', ...(note === undefined ? {} : { note }) };
56
47
  }
57
48
  /** What the page holds for screenshots and videos in each `media` mode. */
58
49
  async function pageMedia(mode, run, outputFile, signal) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e2e-dev/html-reporter",
3
- "version": "0.0.2",
3
+ "version": "0.0.3-nightly-20261120030209",
4
4
  "description": "HTML reporter for e2e: one self-contained page per run, steps, screenshots, and video",
5
5
  "keywords": [
6
6
  "e2e",
@@ -42,7 +42,7 @@
42
42
  "app/Lucide-LICENSE.txt"
43
43
  ],
44
44
  "peerDependencies": {
45
- "e2e": ">=0.23.1 <1"
45
+ "e2e": "0.24.1-nightly-20261120030209"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@tailwindcss/vite": "4.3.5",
@@ -50,7 +50,7 @@
50
50
  "@types/react": "19.3.0",
51
51
  "@types/react-dom": "19.3.0",
52
52
  "@vitejs/plugin-react": "6.3.0",
53
- "e2e": "0.24.0",
53
+ "e2e": "0.24.1-nightly-20261120030209",
54
54
  "lucide-react": "1.76.0",
55
55
  "react": "19.3.1",
56
56
  "react-dom": "19.3.1",