@argos-ci/vitest 0.4.1 → 0.4.3
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/index.d.mts +1 -1
- package/dist/index.mjs +3 -3
- package/dist/internal.d.mts +10 -8
- package/dist/internal.mjs +44 -20
- package/dist/plugin.d.mts +0 -1
- package/dist/plugin.mjs +51 -23
- package/dist/{snapshot-file-DYQmhYf1.mjs → snapshot-file-D8dL3z_T.mjs} +6 -3
- package/package.json +9 -9
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import "@argos-ci/core";
|
|
1
2
|
import { ScreenshotMetadata } from "@argos-ci/util";
|
|
2
3
|
import { ArgosAttachment } from "@argos-ci/playwright";
|
|
3
4
|
import { StabilizationPluginOptions, ViewportOption } from "@argos-ci/browser";
|
|
4
|
-
|
|
5
5
|
//#region src/metadata.d.ts
|
|
6
6
|
/** The `test` slice of {@link ScreenshotMetadata}. */
|
|
7
7
|
type TestMetadata = ScreenshotMetadata["test"];
|
package/dist/index.mjs
CHANGED
|
@@ -138,7 +138,7 @@ async function getTestMetadata() {
|
|
|
138
138
|
return buildTestMetadata(task);
|
|
139
139
|
}
|
|
140
140
|
//#endregion
|
|
141
|
-
//#region ../../node_modules/.pnpm/tinyrainbow@3.1.
|
|
141
|
+
//#region ../../node_modules/.pnpm/tinyrainbow@3.1.1/node_modules/tinyrainbow/dist/index.js
|
|
142
142
|
var b = {
|
|
143
143
|
reset: [0, 0],
|
|
144
144
|
bold: [
|
|
@@ -221,7 +221,7 @@ function C({ force: e } = {}) {
|
|
|
221
221
|
}
|
|
222
222
|
var y = C();
|
|
223
223
|
//#endregion
|
|
224
|
-
//#region ../../node_modules/.pnpm/@vitest+pretty-format@4.1.
|
|
224
|
+
//#region ../../node_modules/.pnpm/@vitest+pretty-format@4.1.10/node_modules/@vitest/pretty-format/dist/index.js
|
|
225
225
|
function _mergeNamespaces(n, m) {
|
|
226
226
|
m.forEach(function(e) {
|
|
227
227
|
e && typeof e !== "string" && !Array.isArray(e) && Object.keys(e).forEach(function(k) {
|
|
@@ -1188,7 +1188,7 @@ async function argosSnapshot(content, options = {}) {
|
|
|
1188
1188
|
const { server } = await import("vitest/browser");
|
|
1189
1189
|
return server.commands.argosSnapshot(resolvedName, serialized, serializableOptions, test);
|
|
1190
1190
|
}
|
|
1191
|
-
const { writeSnapshotFile } = await import("./snapshot-file-
|
|
1191
|
+
const { writeSnapshotFile } = await import("./snapshot-file-D8dL3z_T.mjs");
|
|
1192
1192
|
return writeSnapshotFile(resolvedName, serialized, serializableOptions, test);
|
|
1193
1193
|
}
|
|
1194
1194
|
/**
|
package/dist/internal.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ArgosAttachment, ArgosScreenshotOptions } from "@argos-ci/playwright";
|
|
2
2
|
import { BrowserCommandContext } from "vitest/node";
|
|
3
3
|
import { ViewportSize } from "@argos-ci/browser";
|
|
4
|
-
|
|
5
4
|
//#region src/iframe.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Selector of the iframe Vitest renders the test into on the orchestrator page.
|
|
@@ -26,7 +25,7 @@ declare function resetTesterScale(ctx: BrowserCommandContext): Promise<() => Pro
|
|
|
26
25
|
* box is not painted, so the iframe must be sized to hold the content.
|
|
27
26
|
*
|
|
28
27
|
* @param size - The viewport size, `"default"` to keep the natural size, or
|
|
29
|
-
* `"initial"` to restore the size
|
|
28
|
+
* `"initial"` to restore the size the iframe had before Argos resized it.
|
|
30
29
|
* @param options.fullPage - When `true`, grow the height to fit the content
|
|
31
30
|
* while keeping the viewport width (Playwright-style full page).
|
|
32
31
|
*/
|
|
@@ -36,9 +35,12 @@ declare function setIframeViewportSize(ctx: BrowserCommandContext, size: Viewpor
|
|
|
36
35
|
/**
|
|
37
36
|
* Grow the Vitest iframe to fit its content so nothing is clipped.
|
|
38
37
|
*
|
|
39
|
-
* This must run
|
|
40
|
-
*
|
|
41
|
-
*
|
|
38
|
+
* This must run once the content has reached its final size — after `argosCSS`
|
|
39
|
+
* (which may inject a `zoom`) is applied *and* after stabilization has waited
|
|
40
|
+
* for images and fonts. `setIframeViewportSize` sizes the iframe before any of
|
|
41
|
+
* that, so it can't account for the final content size. It only ever grows the
|
|
42
|
+
* iframe, never shrinks it; use `setIframeViewportSize(ctx, "initial")` to
|
|
43
|
+
* restore the original size afterwards.
|
|
42
44
|
*
|
|
43
45
|
* @param options.fitWidth - Also grow the iframe horizontally to paint content
|
|
44
46
|
* wider than the viewport. When `false`, only the height grows (to match
|
|
@@ -56,9 +58,9 @@ declare function fitIframeToContent(ctx: BrowserCommandContext, options: {
|
|
|
56
58
|
* on. It:
|
|
57
59
|
* - strips the Vitest-specific `viewports`/`fullPage` options (they drive the
|
|
58
60
|
* iframe resize, not Playwright);
|
|
59
|
-
* - wraps `beforeScreenshot` so the
|
|
60
|
-
* (
|
|
61
|
-
*
|
|
61
|
+
* - wraps `beforeScreenshot` so the iframe is grown to fit once the content has
|
|
62
|
+
* settled (see {@link fitIframeToContent}) — otherwise wide/tall content
|
|
63
|
+
* would be clipped;
|
|
62
64
|
* - captures the iframe's `<body>` via `@argos-ci/playwright`.
|
|
63
65
|
*
|
|
64
66
|
* @param config.fitWidth - Grow the iframe horizontally as well as vertically
|
package/dist/internal.mjs
CHANGED
|
@@ -12,6 +12,15 @@ const VITEST_IFRAME_SELECTOR = "iframe[data-vitest=\"true\"]";
|
|
|
12
12
|
*/
|
|
13
13
|
const VITEST_TESTER_ID = "vitest-tester";
|
|
14
14
|
/**
|
|
15
|
+
* Attribute holding the iframe's inline size from before Argos resized it, as
|
|
16
|
+
* JSON.
|
|
17
|
+
*
|
|
18
|
+
* The presence of the attribute — not the values it holds — is what marks the
|
|
19
|
+
* size as backed up: the original `style.width`/`style.height` are usually
|
|
20
|
+
* empty strings, which are indistinguishable from "nothing was saved yet".
|
|
21
|
+
*/
|
|
22
|
+
const SIZE_BACKUP_ATTRIBUTE = "data-argos-size-backup";
|
|
23
|
+
/**
|
|
15
24
|
* Remove the scale from the Vitest `#vitest-tester` element before taking a
|
|
16
25
|
* screenshot to avoid ending up with small screenshots.
|
|
17
26
|
* @returns A function to restore the scale after the screenshot.
|
|
@@ -40,26 +49,29 @@ async function resetTesterScale(ctx) {
|
|
|
40
49
|
* box is not painted, so the iframe must be sized to hold the content.
|
|
41
50
|
*
|
|
42
51
|
* @param size - The viewport size, `"default"` to keep the natural size, or
|
|
43
|
-
* `"initial"` to restore the size
|
|
52
|
+
* `"initial"` to restore the size the iframe had before Argos resized it.
|
|
44
53
|
* @param options.fullPage - When `true`, grow the height to fit the content
|
|
45
54
|
* while keeping the viewport width (Playwright-style full page).
|
|
46
55
|
*/
|
|
47
56
|
async function setIframeViewportSize(ctx, size, options = {}) {
|
|
48
|
-
await ctx.page.evaluate(({ size, fullPage, selector }) => {
|
|
57
|
+
await ctx.page.evaluate(({ size, fullPage, selector, backupAttribute }) => {
|
|
49
58
|
const iframe = document.querySelector(selector);
|
|
50
59
|
if (!(iframe instanceof HTMLIFrameElement)) throw new Error("Vitest iframe not found");
|
|
51
60
|
if (!iframe.contentDocument) throw new Error("Vitest iframe contentDocument not found");
|
|
52
61
|
if (size === "initial") {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
62
|
+
const backup = iframe.getAttribute(backupAttribute);
|
|
63
|
+
if (backup !== null) {
|
|
64
|
+
const { width, height } = JSON.parse(backup);
|
|
65
|
+
iframe.style.width = width;
|
|
66
|
+
iframe.style.height = height;
|
|
67
|
+
iframe.removeAttribute(backupAttribute);
|
|
56
68
|
}
|
|
57
69
|
return;
|
|
58
70
|
}
|
|
59
|
-
if (!iframe.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
71
|
+
if (!iframe.hasAttribute(backupAttribute)) iframe.setAttribute(backupAttribute, JSON.stringify({
|
|
72
|
+
width: iframe.style.width,
|
|
73
|
+
height: iframe.style.height
|
|
74
|
+
}));
|
|
63
75
|
if (size !== "default") iframe.style.width = `${size.width}px`;
|
|
64
76
|
if (fullPage) {
|
|
65
77
|
if (!iframe.contentWindow) throw new Error(`Can't access iframe window`);
|
|
@@ -73,24 +85,32 @@ async function setIframeViewportSize(ctx, size, options = {}) {
|
|
|
73
85
|
}, {
|
|
74
86
|
size,
|
|
75
87
|
fullPage: options.fullPage ?? false,
|
|
76
|
-
selector: VITEST_IFRAME_SELECTOR
|
|
88
|
+
selector: VITEST_IFRAME_SELECTOR,
|
|
89
|
+
backupAttribute: SIZE_BACKUP_ATTRIBUTE
|
|
77
90
|
});
|
|
78
91
|
}
|
|
79
92
|
/**
|
|
80
93
|
* Grow the Vitest iframe to fit its content so nothing is clipped.
|
|
81
94
|
*
|
|
82
|
-
* This must run
|
|
83
|
-
*
|
|
84
|
-
*
|
|
95
|
+
* This must run once the content has reached its final size — after `argosCSS`
|
|
96
|
+
* (which may inject a `zoom`) is applied *and* after stabilization has waited
|
|
97
|
+
* for images and fonts. `setIframeViewportSize` sizes the iframe before any of
|
|
98
|
+
* that, so it can't account for the final content size. It only ever grows the
|
|
99
|
+
* iframe, never shrinks it; use `setIframeViewportSize(ctx, "initial")` to
|
|
100
|
+
* restore the original size afterwards.
|
|
85
101
|
*
|
|
86
102
|
* @param options.fitWidth - Also grow the iframe horizontally to paint content
|
|
87
103
|
* wider than the viewport. When `false`, only the height grows (to match
|
|
88
104
|
* Playwright's `fullPage` semantics: full height, viewport width).
|
|
89
105
|
*/
|
|
90
106
|
async function fitIframeToContent(ctx, options) {
|
|
91
|
-
await ctx.page.evaluate(({ fitWidth, selector }) => {
|
|
107
|
+
await ctx.page.evaluate(({ fitWidth, selector, backupAttribute }) => {
|
|
92
108
|
const iframe = document.querySelector(selector);
|
|
93
109
|
if (!(iframe instanceof HTMLIFrameElement) || !iframe.contentDocument) return;
|
|
110
|
+
if (!iframe.hasAttribute(backupAttribute)) iframe.setAttribute(backupAttribute, JSON.stringify({
|
|
111
|
+
width: iframe.style.width,
|
|
112
|
+
height: iframe.style.height
|
|
113
|
+
}));
|
|
94
114
|
const { body, documentElement } = iframe.contentDocument;
|
|
95
115
|
const contentHeight = Math.max(body.scrollHeight, body.offsetHeight, documentElement.scrollHeight);
|
|
96
116
|
if (contentHeight > iframe.clientHeight) iframe.style.height = `${contentHeight}px`;
|
|
@@ -100,7 +120,8 @@ async function fitIframeToContent(ctx, options) {
|
|
|
100
120
|
}
|
|
101
121
|
}, {
|
|
102
122
|
fitWidth: options.fitWidth,
|
|
103
|
-
selector: VITEST_IFRAME_SELECTOR
|
|
123
|
+
selector: VITEST_IFRAME_SELECTOR,
|
|
124
|
+
backupAttribute: SIZE_BACKUP_ATTRIBUTE
|
|
104
125
|
});
|
|
105
126
|
}
|
|
106
127
|
//#endregion
|
|
@@ -112,9 +133,9 @@ async function fitIframeToContent(ctx, options) {
|
|
|
112
133
|
* on. It:
|
|
113
134
|
* - strips the Vitest-specific `viewports`/`fullPage` options (they drive the
|
|
114
135
|
* iframe resize, not Playwright);
|
|
115
|
-
* - wraps `beforeScreenshot` so the
|
|
116
|
-
* (
|
|
117
|
-
*
|
|
136
|
+
* - wraps `beforeScreenshot` so the iframe is grown to fit once the content has
|
|
137
|
+
* settled (see {@link fitIframeToContent}) — otherwise wide/tall content
|
|
138
|
+
* would be clipped;
|
|
118
139
|
* - captures the iframe's `<body>` via `@argos-ci/playwright`.
|
|
119
140
|
*
|
|
120
141
|
* @param config.fitWidth - Grow the iframe horizontally as well as vertically
|
|
@@ -127,10 +148,12 @@ async function screenshotFrame(ctx, name, options, config) {
|
|
|
127
148
|
...rest,
|
|
128
149
|
beforeScreenshot: async (api) => {
|
|
129
150
|
await userBeforeScreenshot?.(api);
|
|
151
|
+
await api.runStabilization();
|
|
130
152
|
await fitIframeToContent(ctx, { fitWidth: config.fitWidth });
|
|
131
153
|
}
|
|
132
154
|
};
|
|
133
|
-
|
|
155
|
+
const frame = await ctx.frame();
|
|
156
|
+
return argosScreenshot(frame, name, playwrightOptions);
|
|
134
157
|
}
|
|
135
158
|
//#endregion
|
|
136
159
|
//#region src/version.ts
|
|
@@ -139,7 +162,8 @@ const require = createRequire(import.meta.url);
|
|
|
139
162
|
* Get the version of the Argos Vitest SDK.
|
|
140
163
|
*/
|
|
141
164
|
async function getArgosVitestVersion() {
|
|
142
|
-
|
|
165
|
+
const pkgPath = require.resolve("@argos-ci/vitest/package.json");
|
|
166
|
+
return readVersionFromPackage(pkgPath);
|
|
143
167
|
}
|
|
144
168
|
//#endregion
|
|
145
169
|
export { VITEST_IFRAME_SELECTOR, VITEST_TESTER_ID, fitIframeToContent, getArgosVitestVersion, resetTesterScale, screenshotFrame, setIframeViewportSize };
|
package/dist/plugin.d.mts
CHANGED
|
@@ -5,7 +5,6 @@ import { UploadParameters } from "@argos-ci/core";
|
|
|
5
5
|
import { Plugin } from "vitest/config";
|
|
6
6
|
import { BrowserCommand, Vitest } from "vitest/node";
|
|
7
7
|
import { Reporter } from "vitest/reporters";
|
|
8
|
-
|
|
9
8
|
//#region src/options.d.ts
|
|
10
9
|
/**
|
|
11
10
|
* Configuration for the Argos Vitest reporter.
|
package/dist/plugin.mjs
CHANGED
|
@@ -16,6 +16,15 @@ const VITEST_IFRAME_SELECTOR = "iframe[data-vitest=\"true\"]";
|
|
|
16
16
|
*/
|
|
17
17
|
const VITEST_TESTER_ID = "vitest-tester";
|
|
18
18
|
/**
|
|
19
|
+
* Attribute holding the iframe's inline size from before Argos resized it, as
|
|
20
|
+
* JSON.
|
|
21
|
+
*
|
|
22
|
+
* The presence of the attribute — not the values it holds — is what marks the
|
|
23
|
+
* size as backed up: the original `style.width`/`style.height` are usually
|
|
24
|
+
* empty strings, which are indistinguishable from "nothing was saved yet".
|
|
25
|
+
*/
|
|
26
|
+
const SIZE_BACKUP_ATTRIBUTE = "data-argos-size-backup";
|
|
27
|
+
/**
|
|
19
28
|
* Remove the scale from the Vitest `#vitest-tester` element before taking a
|
|
20
29
|
* screenshot to avoid ending up with small screenshots.
|
|
21
30
|
* @returns A function to restore the scale after the screenshot.
|
|
@@ -44,26 +53,29 @@ async function resetTesterScale(ctx) {
|
|
|
44
53
|
* box is not painted, so the iframe must be sized to hold the content.
|
|
45
54
|
*
|
|
46
55
|
* @param size - The viewport size, `"default"` to keep the natural size, or
|
|
47
|
-
* `"initial"` to restore the size
|
|
56
|
+
* `"initial"` to restore the size the iframe had before Argos resized it.
|
|
48
57
|
* @param options.fullPage - When `true`, grow the height to fit the content
|
|
49
58
|
* while keeping the viewport width (Playwright-style full page).
|
|
50
59
|
*/
|
|
51
60
|
async function setIframeViewportSize(ctx, size, options = {}) {
|
|
52
|
-
await ctx.page.evaluate(({ size, fullPage, selector }) => {
|
|
61
|
+
await ctx.page.evaluate(({ size, fullPage, selector, backupAttribute }) => {
|
|
53
62
|
const iframe = document.querySelector(selector);
|
|
54
63
|
if (!(iframe instanceof HTMLIFrameElement)) throw new Error("Vitest iframe not found");
|
|
55
64
|
if (!iframe.contentDocument) throw new Error("Vitest iframe contentDocument not found");
|
|
56
65
|
if (size === "initial") {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
66
|
+
const backup = iframe.getAttribute(backupAttribute);
|
|
67
|
+
if (backup !== null) {
|
|
68
|
+
const { width, height } = JSON.parse(backup);
|
|
69
|
+
iframe.style.width = width;
|
|
70
|
+
iframe.style.height = height;
|
|
71
|
+
iframe.removeAttribute(backupAttribute);
|
|
60
72
|
}
|
|
61
73
|
return;
|
|
62
74
|
}
|
|
63
|
-
if (!iframe.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
75
|
+
if (!iframe.hasAttribute(backupAttribute)) iframe.setAttribute(backupAttribute, JSON.stringify({
|
|
76
|
+
width: iframe.style.width,
|
|
77
|
+
height: iframe.style.height
|
|
78
|
+
}));
|
|
67
79
|
if (size !== "default") iframe.style.width = `${size.width}px`;
|
|
68
80
|
if (fullPage) {
|
|
69
81
|
if (!iframe.contentWindow) throw new Error(`Can't access iframe window`);
|
|
@@ -77,24 +89,32 @@ async function setIframeViewportSize(ctx, size, options = {}) {
|
|
|
77
89
|
}, {
|
|
78
90
|
size,
|
|
79
91
|
fullPage: options.fullPage ?? false,
|
|
80
|
-
selector: VITEST_IFRAME_SELECTOR
|
|
92
|
+
selector: VITEST_IFRAME_SELECTOR,
|
|
93
|
+
backupAttribute: SIZE_BACKUP_ATTRIBUTE
|
|
81
94
|
});
|
|
82
95
|
}
|
|
83
96
|
/**
|
|
84
97
|
* Grow the Vitest iframe to fit its content so nothing is clipped.
|
|
85
98
|
*
|
|
86
|
-
* This must run
|
|
87
|
-
*
|
|
88
|
-
*
|
|
99
|
+
* This must run once the content has reached its final size — after `argosCSS`
|
|
100
|
+
* (which may inject a `zoom`) is applied *and* after stabilization has waited
|
|
101
|
+
* for images and fonts. `setIframeViewportSize` sizes the iframe before any of
|
|
102
|
+
* that, so it can't account for the final content size. It only ever grows the
|
|
103
|
+
* iframe, never shrinks it; use `setIframeViewportSize(ctx, "initial")` to
|
|
104
|
+
* restore the original size afterwards.
|
|
89
105
|
*
|
|
90
106
|
* @param options.fitWidth - Also grow the iframe horizontally to paint content
|
|
91
107
|
* wider than the viewport. When `false`, only the height grows (to match
|
|
92
108
|
* Playwright's `fullPage` semantics: full height, viewport width).
|
|
93
109
|
*/
|
|
94
110
|
async function fitIframeToContent(ctx, options) {
|
|
95
|
-
await ctx.page.evaluate(({ fitWidth, selector }) => {
|
|
111
|
+
await ctx.page.evaluate(({ fitWidth, selector, backupAttribute }) => {
|
|
96
112
|
const iframe = document.querySelector(selector);
|
|
97
113
|
if (!(iframe instanceof HTMLIFrameElement) || !iframe.contentDocument) return;
|
|
114
|
+
if (!iframe.hasAttribute(backupAttribute)) iframe.setAttribute(backupAttribute, JSON.stringify({
|
|
115
|
+
width: iframe.style.width,
|
|
116
|
+
height: iframe.style.height
|
|
117
|
+
}));
|
|
98
118
|
const { body, documentElement } = iframe.contentDocument;
|
|
99
119
|
const contentHeight = Math.max(body.scrollHeight, body.offsetHeight, documentElement.scrollHeight);
|
|
100
120
|
if (contentHeight > iframe.clientHeight) iframe.style.height = `${contentHeight}px`;
|
|
@@ -104,7 +124,8 @@ async function fitIframeToContent(ctx, options) {
|
|
|
104
124
|
}
|
|
105
125
|
}, {
|
|
106
126
|
fitWidth: options.fitWidth,
|
|
107
|
-
selector: VITEST_IFRAME_SELECTOR
|
|
127
|
+
selector: VITEST_IFRAME_SELECTOR,
|
|
128
|
+
backupAttribute: SIZE_BACKUP_ATTRIBUTE
|
|
108
129
|
});
|
|
109
130
|
}
|
|
110
131
|
//#endregion
|
|
@@ -116,9 +137,9 @@ async function fitIframeToContent(ctx, options) {
|
|
|
116
137
|
* on. It:
|
|
117
138
|
* - strips the Vitest-specific `viewports`/`fullPage` options (they drive the
|
|
118
139
|
* iframe resize, not Playwright);
|
|
119
|
-
* - wraps `beforeScreenshot` so the
|
|
120
|
-
* (
|
|
121
|
-
*
|
|
140
|
+
* - wraps `beforeScreenshot` so the iframe is grown to fit once the content has
|
|
141
|
+
* settled (see {@link fitIframeToContent}) — otherwise wide/tall content
|
|
142
|
+
* would be clipped;
|
|
122
143
|
* - captures the iframe's `<body>` via `@argos-ci/playwright`.
|
|
123
144
|
*
|
|
124
145
|
* @param config.fitWidth - Grow the iframe horizontally as well as vertically
|
|
@@ -131,10 +152,12 @@ async function screenshotFrame(ctx, name, options, config) {
|
|
|
131
152
|
...rest,
|
|
132
153
|
beforeScreenshot: async (api) => {
|
|
133
154
|
await userBeforeScreenshot?.(api);
|
|
155
|
+
await api.runStabilization();
|
|
134
156
|
await fitIframeToContent(ctx, { fitWidth: config.fitWidth });
|
|
135
157
|
}
|
|
136
158
|
};
|
|
137
|
-
|
|
159
|
+
const frame = await ctx.frame();
|
|
160
|
+
return argosScreenshot(frame, name, playwrightOptions);
|
|
138
161
|
}
|
|
139
162
|
//#endregion
|
|
140
163
|
//#region src/version.ts
|
|
@@ -143,14 +166,16 @@ const require = createRequire(import.meta.url);
|
|
|
143
166
|
* Get the version of the Argos Vitest SDK.
|
|
144
167
|
*/
|
|
145
168
|
async function getArgosVitestVersion() {
|
|
146
|
-
|
|
169
|
+
const pkgPath = require.resolve("@argos-ci/vitest/package.json");
|
|
170
|
+
return readVersionFromPackage(pkgPath);
|
|
147
171
|
}
|
|
148
172
|
/**
|
|
149
173
|
* Get the version of Vitest itself (used as the automation library for
|
|
150
174
|
* `argosSnapshot`, which does not rely on a browser).
|
|
151
175
|
*/
|
|
152
176
|
async function getVitestVersion() {
|
|
153
|
-
|
|
177
|
+
const pkgPath = require.resolve("vitest/package.json");
|
|
178
|
+
return readVersionFromPackage(pkgPath);
|
|
154
179
|
}
|
|
155
180
|
//#endregion
|
|
156
181
|
//#region src/command.ts
|
|
@@ -206,6 +231,7 @@ const createArgosScreenshotCommand = (pluginOptions = {}) => {
|
|
|
206
231
|
}
|
|
207
232
|
return attachments;
|
|
208
233
|
} finally {
|
|
234
|
+
await setIframeViewportSize(ctx, "initial");
|
|
209
235
|
await restore();
|
|
210
236
|
}
|
|
211
237
|
};
|
|
@@ -254,7 +280,8 @@ async function writeSnapshotFile(name, content, options = {}, test) {
|
|
|
254
280
|
if (!name) throw new Error("The `name` argument is required.");
|
|
255
281
|
const root = options.root ?? "./snapshots";
|
|
256
282
|
const extension = normalizeExtension(options.extension ?? DEFAULT_EXTENSION);
|
|
257
|
-
const
|
|
283
|
+
const filename = `${getScreenshotName(name)}${SNAPSHOT_INFIX}${extension}`;
|
|
284
|
+
const snapshotPath = resolve(root, filename);
|
|
258
285
|
const [vitestVersion, sdkVersion, resolvedTest] = await Promise.all([
|
|
259
286
|
getVitestVersion(),
|
|
260
287
|
getArgosVitestVersion(),
|
|
@@ -343,6 +370,7 @@ var ArgosReporter = class {
|
|
|
343
370
|
if (this.vitest.config.watch) return;
|
|
344
371
|
const { ignoreUploadFailures, ...uploadParameters } = this.config;
|
|
345
372
|
try {
|
|
373
|
+
const parallel = await getParallelFromConfig(this.vitest.config);
|
|
346
374
|
const res = await upload({
|
|
347
375
|
files: [
|
|
348
376
|
"**/*.png",
|
|
@@ -350,7 +378,7 @@ var ArgosReporter = class {
|
|
|
350
378
|
"**/*.snapshot.*"
|
|
351
379
|
],
|
|
352
380
|
ignore: ["**/*.argos.json"],
|
|
353
|
-
parallel:
|
|
381
|
+
parallel: parallel ?? void 0,
|
|
354
382
|
...uploadParameters
|
|
355
383
|
});
|
|
356
384
|
console.log(`✅ Argos build created: ${res.build.url}`);
|
|
@@ -9,14 +9,16 @@ const require = createRequire(import.meta.url);
|
|
|
9
9
|
* Get the version of the Argos Vitest SDK.
|
|
10
10
|
*/
|
|
11
11
|
async function getArgosVitestVersion() {
|
|
12
|
-
|
|
12
|
+
const pkgPath = require.resolve("@argos-ci/vitest/package.json");
|
|
13
|
+
return readVersionFromPackage(pkgPath);
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* Get the version of Vitest itself (used as the automation library for
|
|
16
17
|
* `argosSnapshot`, which does not rely on a browser).
|
|
17
18
|
*/
|
|
18
19
|
async function getVitestVersion() {
|
|
19
|
-
|
|
20
|
+
const pkgPath = require.resolve("vitest/package.json");
|
|
21
|
+
return readVersionFromPackage(pkgPath);
|
|
20
22
|
}
|
|
21
23
|
//#endregion
|
|
22
24
|
//#region src/snapshot-file.ts
|
|
@@ -62,7 +64,8 @@ async function writeSnapshotFile(name, content, options = {}, test) {
|
|
|
62
64
|
if (!name) throw new Error("The `name` argument is required.");
|
|
63
65
|
const root = options.root ?? "./snapshots";
|
|
64
66
|
const extension = normalizeExtension(options.extension ?? DEFAULT_EXTENSION);
|
|
65
|
-
const
|
|
67
|
+
const filename = `${getScreenshotName(name)}${SNAPSHOT_INFIX}${extension}`;
|
|
68
|
+
const snapshotPath = resolve(root, filename);
|
|
66
69
|
const [vitestVersion, sdkVersion, resolvedTest] = await Promise.all([
|
|
67
70
|
getVitestVersion(),
|
|
68
71
|
getArgosVitestVersion(),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@argos-ci/vitest",
|
|
3
3
|
"description": "Vitest SDK for visual testing with Argos.",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.3",
|
|
5
5
|
"author": "Smooth Code",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"node": ">=22.0.0"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@argos-ci/browser": "6.4.
|
|
55
|
-
"@argos-ci/core": "6.7.
|
|
56
|
-
"@argos-ci/playwright": "7.4.
|
|
54
|
+
"@argos-ci/browser": "6.4.5",
|
|
55
|
+
"@argos-ci/core": "6.7.2",
|
|
56
|
+
"@argos-ci/playwright": "7.4.3",
|
|
57
57
|
"@argos-ci/util": "4.1.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
@@ -64,10 +64,10 @@
|
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/node": "catalog:",
|
|
67
|
-
"@vitest/browser": "^4.1.
|
|
68
|
-
"@vitest/browser-playwright": "^4.1.
|
|
69
|
-
"@vitest/pretty-format": "^4.1.
|
|
70
|
-
"playwright": "^1.
|
|
67
|
+
"@vitest/browser": "^4.1.10",
|
|
68
|
+
"@vitest/browser-playwright": "^4.1.10",
|
|
69
|
+
"@vitest/pretty-format": "^4.1.10",
|
|
70
|
+
"playwright": "^1.62.1",
|
|
71
71
|
"vitest": "catalog:"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"check-format": "prettier --check --ignore-unknown --ignore-path=./.gitignore --ignore-path=../../.gitignore --ignore-path=../../.prettierignore .",
|
|
82
82
|
"lint": "eslint ."
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "fd20b0af878b8186d6950c2e9c4ab381ca3fcaa1"
|
|
85
85
|
}
|