Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.
TypeScript apifyautomationcrawlercrawlingheadlessheadless-chromejavascriptnodejsnpmplaywrightpuppeteerscraperscrapingtypescriptweb-crawlerweb-crawlingweb-scraping
Fix saveSnapshot lint and test
Ondra Urban28c86948298f
diff --git a/src/puppeteer_utils.js b/src/puppeteer_utils.jsindex 77f607b33..61bc0c4fe 100644--- a/src/puppeteer_utils.js+++ b/src/puppeteer_utils.js@@ -5,7 +5,6 @@ import * as util from 'util';import * as _ from 'underscore';import * as LruCache from 'apify-shared/lru_cache';import { Page, Response, DirectNavigationOptions } from 'puppeteer'; // eslint-disable-line no-unused-vars-import { isAtHome } from './utils';import log from './utils_log';import { validators } from './validators';diff --git a/test/puppeteer_utils.test.js b/test/puppeteer_utils.test.jsindex ec17447f4..a74afe934 100644--- a/test/puppeteer_utils.test.js+++ b/test/puppeteer_utils.test.js@@ -376,8 +376,8 @@ describe('Apify.utils.puppeteer', () => {await Apify.utils.puppeteer.saveSnapshot(page, { key: 'TEST', keyValueStoreName: 'TEST-STORE', screenshotQuality: 60 });- expect(stub.calledWithExactly('TEST', screenshot, { contentType: 'image/jpeg' })).toBe(true);- expect(stub.calledWithExactly('TEST', contentHTML, { contentType: 'text/html' })).toBe(true);+ expect(stub.calledWithExactly('TEST.jpg', screenshot, { contentType: 'image/jpeg' })).toBe(true);+ expect(stub.calledWithExactly('TEST.html', contentHTML, { contentType: 'text/html' })).toBe(true);// Test saving only imageconst object2 = { setValue: async () => {} };@@ -390,23 +390,7 @@ describe('Apify.utils.puppeteer', () => {// Default quality is 50const screenshot2 = await page.screenshot({ fullPage: true, type: 'jpeg', screenshotQuality: 50 });- expect(stub2.calledOnceWithExactly('SNAPSHOT', screenshot2, { contentType: 'image/jpeg' })).toBe(true);-- // Test saving both image and html on the platform- process.env[ENV_VARS.IS_AT_HOME] = 1;-- const object3 = { setValue: async () => {} };- const stub3 = sinon.stub(object3, 'setValue');- mock.expects('openKeyValueStore')- .once()- .withExactArgs('TEST-STORE')- .resolves(object3);-- await Apify.utils.puppeteer.saveSnapshot(page, { key: 'TEST', keyValueStoreName: 'TEST-STORE', screenshotQuality: 60 });-- expect(stub3.calledWithExactly('TEST.jpg', screenshot, { contentType: 'image/jpeg' })).toBe(true);- expect(stub3.calledWithExactly('TEST.html', contentHTML, { contentType: 'text/html' })).toBe(true);- delete process.env[ENV_VARS.IS_AT_HOME];+ expect(stub2.calledOnceWithExactly('SNAPSHOT.jpg', screenshot2, { contentType: 'image/jpeg' })).toBe(true);mock.verify();} finally {