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

Update puppeteer dependencies to latest version #481

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"commander": "^11.0.0",
"console-stamp": "^3.1.1",
"express": "^4.18.2",
"puppeteer": "^21.0.2",
"puppeteer-autoscroll-down": "^1.1.2",
"puppeteer-core": "^21.0.2"
"puppeteer": "^23.1.0",
"puppeteer-autoscroll-down": "^2.0.0",
"puppeteer-core": "^23.1.0"
},
"devDependencies": {
"@commitlint/cli": "18.4.4",
Expand Down
5 changes: 3 additions & 2 deletions src/core.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import chalk from 'chalk';
import console_stamp from 'console-stamp';
import * as puppeteer from 'puppeteer-core';
import { scrollPageToBottom } from 'puppeteer-autoscroll-down';
import * as fs from 'fs-extra';
import { chromeExecPath } from './browser';
import * as utils from './utils';
Expand Down Expand Up @@ -66,7 +65,7 @@ export async function generatePDF({
const execPath = process.env.PUPPETEER_EXECUTABLE_PATH ?? chromeExecPath();
console.debug(chalk.cyan(`Using Chromium from ${execPath}`));
const browser = await puppeteer.launch({
headless: 'new',
headless: true,
executablePath: execPath,
args: puppeteerArgs,
protocolTimeout: protocolTimeout,
Expand Down Expand Up @@ -184,6 +183,8 @@ export async function generatePDF({
// Scroll to the bottom of the page with puppeteer-autoscroll-down
// This forces lazy-loading images to load
console.log(chalk.cyan('Scroll to the bottom of the page...'));

const { scrollPageToBottom } = await import('puppeteer-autoscroll-down');
await scrollPageToBottom(page, {}); //cast to puppeteer-core type

// Generate PDF
Expand Down
16 changes: 8 additions & 8 deletions tests/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ describe('getHtmlContent', () => {

beforeAll(async () => {
browser = await puppeteer.launch({
headless: 'new',
headless: true,
executablePath: execPath,
});
page = await browser.newPage();
}, 30000);
}, 60000);

afterAll(async () => {
await browser.close();
Expand Down Expand Up @@ -56,7 +56,7 @@ describe('findNextUrl', () => {

beforeAll(async () => {
browser = await puppeteer.launch({
headless: 'new',
headless: true,
executablePath: execPath,
});
page = await browser.newPage();
Expand Down Expand Up @@ -86,7 +86,7 @@ describe('removeExcludeSelector', () => {

beforeAll(async () => {
browser = await puppeteer.launch({
headless: 'new',
headless: true,
executablePath: execPath,
});
page = await browser.newPage();
Expand Down Expand Up @@ -141,7 +141,7 @@ describe('getCoverImage', () => {

beforeAll(async () => {
browser = await puppeteer.launch({
headless: 'new',
headless: true,
executablePath: execPath,
});
page = await browser.newPage();
Expand Down Expand Up @@ -277,7 +277,7 @@ describe('matchKeyword', () => {

beforeAll(async () => {
browser = await puppeteer.launch({
headless: 'new',
headless: true,
executablePath: execPath,
});
page = await browser.newPage();
Expand Down Expand Up @@ -324,7 +324,7 @@ describe('isPageKept function', () => {

beforeAll(async () => {
browser = await puppeteer.launch({
headless: 'new',
headless: true,
executablePath: execPath,
});
page = await browser.newPage();
Expand Down Expand Up @@ -474,7 +474,7 @@ describe('openDetails function', () => {

beforeAll(async () => {
browser = await puppeteer.launch({
headless: 'new',
headless: true,
executablePath: execPath,
});
page = await browser.newPage();
Expand Down
Loading