@argos-ci/storybook 6.0.16 → 6.0.18
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/vitest-plugin.mjs +20 -1
- package/package.json +2 -2
package/dist/vitest-plugin.mjs
CHANGED
|
@@ -270,6 +270,25 @@ const createArgosScreenshotCommand = (pluginOptions) => {
|
|
|
270
270
|
const frame = await ctx.frame();
|
|
271
271
|
const fitToContent = getFitToContentFromParameters(testContext.story.parameters);
|
|
272
272
|
const after = await before(ctx);
|
|
273
|
+
const options = applyFitToContent(screenshotOptions, fitToContent);
|
|
274
|
+
const userBeforeScreenshot = options?.beforeScreenshot;
|
|
275
|
+
const optionsWithFit = {
|
|
276
|
+
...options,
|
|
277
|
+
beforeScreenshot: async (api) => {
|
|
278
|
+
await userBeforeScreenshot?.(api);
|
|
279
|
+
await ctx.page.evaluate(({ fitWidth }) => {
|
|
280
|
+
const iframe = document.querySelector("iframe[data-vitest=\"true\"]");
|
|
281
|
+
if (!(iframe instanceof HTMLIFrameElement) || !iframe.contentDocument) return;
|
|
282
|
+
const { body, documentElement } = iframe.contentDocument;
|
|
283
|
+
const contentHeight = Math.max(body.scrollHeight, body.offsetHeight, documentElement.scrollHeight);
|
|
284
|
+
if (contentHeight > iframe.clientHeight) iframe.style.height = `${contentHeight}px`;
|
|
285
|
+
if (fitWidth) {
|
|
286
|
+
const contentWidth = Math.max(body.scrollWidth, body.offsetWidth, documentElement.scrollWidth);
|
|
287
|
+
if (contentWidth > iframe.clientWidth) iframe.style.width = `${contentWidth}px`;
|
|
288
|
+
}
|
|
289
|
+
}, { fitWidth: Boolean(fitToContent) });
|
|
290
|
+
}
|
|
291
|
+
};
|
|
273
292
|
const attachments = await storybookArgosScreenshot(frame, {
|
|
274
293
|
...testContext,
|
|
275
294
|
playwrightLibraries: ["@storybook/addon-vitest"],
|
|
@@ -304,7 +323,7 @@ const createArgosScreenshotCommand = (pluginOptions) => {
|
|
|
304
323
|
fullPage: screenshotOptions.fullPage ?? !fitToContent
|
|
305
324
|
});
|
|
306
325
|
}
|
|
307
|
-
},
|
|
326
|
+
}, optionsWithFit);
|
|
308
327
|
await after();
|
|
309
328
|
return attachments;
|
|
310
329
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@argos-ci/storybook",
|
|
3
3
|
"description": "Visual testing for Storybook test runner.",
|
|
4
|
-
"version": "6.0.
|
|
4
|
+
"version": "6.0.18",
|
|
5
5
|
"author": "Smooth Code",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -98,5 +98,5 @@
|
|
|
98
98
|
"check-format": "prettier --check --ignore-unknown --ignore-path=./.gitignore --ignore-path=../../.gitignore --ignore-path=../../.prettierignore .",
|
|
99
99
|
"lint": "eslint ."
|
|
100
100
|
},
|
|
101
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "caaf0f8f6389199e4b94ea43cd014ff72becec94"
|
|
102
102
|
}
|