Skip to content

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.

Add tests for puppeteerModule, update changelog

Ondra Urban8759062d372e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3c44ef68f..f0ad1fe41 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,7 @@
NEXT
====================
+- Improved `Apify.launchPuppeteer()` code to prevent triggering bugs in Puppeteer by passing
+ more than required options to `puppeteer.launch()`.
0.19.1 / 2020-01-30
====================
diff --git a/test/puppeteer.test.js b/test/puppeteer.test.js
index 506ec0545..3a92bc53d 100644
--- a/test/puppeteer.test.js
+++ b/test/puppeteer.test.js
@@ -238,17 +238,42 @@ describe('Apify.launchPuppeteer()', () => {
}
});
- test(
- 'should throw when useApifyProxy=true and proxy password is not set',
- () => {
- const opts = {
- useApifyProxy: true,
- apifyProxySession: 'xxx',
- apifyProxyGroups: ['yyy'],
- headless: true,
- };
+ test('should throw when useApifyProxy=true and proxy password is not set', () => {
+ const opts = {
+ useApifyProxy: true,
+ apifyProxySession: 'xxx',
+ apifyProxyGroups: ['yyy'],
+ headless: true,
+ };
+
+ expect(Apify.launchPuppeteer(opts)).rejects.toThrow(Error);
+ });
- expect(Apify.launchPuppeteer(opts)).rejects.toThrow(Error);
- },
- );
+ test('puppeteerModule option works with type string', async () => {
+ let browser;
+ try {
+ browser = await Apify.launchPuppeteer({
+ puppeteerModule: 'puppeteer',
+ });
+ } finally {
+ if (browser) await browser.close();
+ }
+ });
+
+ test('puppeteerModule option works with type object', async () => {
+ const someProps = { foo: 'bar' };
+ // Make it circular for extra security.
+ someProps.props = someProps;
+ let browser;
+ try {
+ browser = await Apify.launchPuppeteer({
+ puppeteerModule: {
+ launch: async () => {},
+ someProps,
+ },
+ });
+ } finally {
+ if (browser) await browser.close();
+ }
+ });
});