Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Upgdate CI Puppeteer to latest #901

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: Upgrade puppeteer-core to latest
Quramy committed Sep 3, 2024
commit eb1e37c95b949938af86218ac75c6fefb078e488
9 changes: 7 additions & 2 deletions packages/storycap/src/node/capturing-browser.ts
Original file line number Diff line number Diff line change
@@ -372,7 +372,8 @@ export class CapturingBrowser extends StoryPreviewBrowser {
let emittedScreenshotOptions: ScreenshotOptions | undefined;
this.resourceWatcher.clear();

function onConsoleLog(msg: ConsoleMessage) {
function onConsoleLog(_msg: any) {
const msg = _msg as ConsoleMessage;
const niceMessage = `From ${requestId} (${msg.type()}): ${msg.text()}`;

if (forwardConsoleLogs) {
@@ -468,6 +469,8 @@ export class CapturingBrowser extends StoryPreviewBrowser {
let buffer: Buffer | null = null;
if (Buffer.isBuffer(rawBuffer)) {
buffer = rawBuffer;
} else if (rawBuffer instanceof Uint8Array) {
buffer = Buffer.from(rawBuffer);
}

// We should reset elements state(e.g. focusing, hovering, clicking) for future screenshot for this story.
@@ -490,7 +493,9 @@ export class CapturingBrowser extends StoryPreviewBrowser {

// Calculate the suffix and save the trace to the file.
const suffix = variantKey.isDefault && defaultVariantSuffix ? [defaultVariantSuffix] : variantKey.keys;
await fileSystem.saveTrace(story.kind, story.story, suffix, traceBuffer);
if (traceBuffer) {
await fileSystem.saveTrace(story.kind, story.story, suffix, Buffer.from(traceBuffer));
}
}
}
}
2 changes: 1 addition & 1 deletion packages/storycrawler/package.json
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@
},
"dependencies": {
"chalk": "^2.4.1",
"puppeteer-core": "^9.0.0",
"puppeteer-core": "^23.2.1",
"wait-on": "^7.0.0"
},
"jest": {
3 changes: 2 additions & 1 deletion packages/storycrawler/src/browser/devices.ts
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import type { Viewport } from 'puppeteer-core';
*
*/
export function getDeviceDescriptors() {
const dd = require('puppeteer-core').devices as Record<string, { name: string; viewport: Viewport }>;
const pc = require('puppeteer-core');
const dd = (pc.KnownDevices || pc.devices) as Record<string, { name: string; viewport: Viewport }>;
return Object.values(dd);
}
3 changes: 2 additions & 1 deletion packages/storycrawler/src/browser/stories-browser.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { setTimeout as nodeSetTimeout } from 'node:timers/promises';
import { BaseBrowser, BaseBrowserOptions } from './base-browser';
import { Logger } from '../logger';
import { NoStoriesError, StoriesTimeoutError } from '../errors';
@@ -77,7 +78,7 @@ export class StoriesBrowser extends BaseBrowser {
timeout: 60_000,
},
);
await this.page.waitForTimeout(500);
await nodeSetTimeout(500);
await this.page.evaluate(() => {
const api = (window as ExposedWindow).__STORYBOOK_CLIENT_API__ || (window as ExposedWindow).__STORYBOOK_PREVIEW__;
function isPreviewApi(api: API | PreviewAPI): api is PreviewAPI {
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
@@ -8397,7 +8397,7 @@ punycode@^2.1.0, punycode@^2.1.1:
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5"
integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==

[email protected]:
[email protected], puppeteer-core@^23.2.1:
version "23.2.1"
resolved "https://registry.yarnpkg.com/puppeteer-core/-/puppeteer-core-23.2.1.tgz#ba77f439f36b59d23c50186460d7538b938442e8"
integrity sha512-AIFWfQ4Sq+En+OgqIUy8VJmD8yJHMDyt+qEmEVKW07zu5DKDNqysO7fzBZp0W85ShJTUlUf+RleKl4XLwFpUPA==