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.

test: Update fix-playwright-multi-run e2e test (#3012)

Jan Bucharaf5aac3029d9
diff --git a/test/e2e/playwright-multi-run/actor/main.js b/test/e2e/playwright-multi-run/actor/main.js
index 3f10d8b58..97b23ecc4 100644
--- a/test/e2e/playwright-multi-run/actor/main.js
+++ b/test/e2e/playwright-multi-run/actor/main.js
@@ -9,8 +9,9 @@ if (process.env.STORAGE_IMPLEMENTATION === 'LOCAL') {
const crawler = new PlaywrightCrawler({
maxRequestsPerCrawl: 10,
- async requestHandler({ page, enqueueLinks, request }) {
+ async requestHandler({ log, page, enqueueLinks, request }) {
const { url } = request;
+ log.info(`Processing ${url}...`);
const pageTitle = await page.title();
await Dataset.pushData({ url, pageTitle });
await enqueueLinks({
@@ -19,8 +20,11 @@ const crawler = new PlaywrightCrawler({
},
});
-await crawler.run(['https://crawlee.dev/js/docs/3.0/examples/']);
-await crawler.run(['https://crawlee.dev/js/docs/3.0/examples/']);
-await crawler.run(['https://crawlee.dev/js/docs/3.0/examples/']);
+crawler.log.info('=== Run 1 ===');
+await crawler.run(['https://crawlee.dev/js/docs/3.0/examples']);
+crawler.log.info('=== Run 2 ===');
+await crawler.run(['https://crawlee.dev/js/docs/3.0/examples']);
+crawler.log.info('=== Run 3 ===');
+await crawler.run(['https://crawlee.dev/js/docs/3.0/examples']);
await Actor.exit({ exit: Actor.isAtHome() });
diff --git a/test/e2e/playwright-multi-run/test.mjs b/test/e2e/playwright-multi-run/test.mjs
index 3a8e741ab..a9b574b72 100644
--- a/test/e2e/playwright-multi-run/test.mjs
+++ b/test/e2e/playwright-multi-run/test.mjs
@@ -10,5 +10,5 @@ await initialize(testActorDirname);
const { datasetItems } = await runActor(testActorDirname, 16384);
// we cant assert number of requests as the stats KVS is being wiped on each `run` call, unlike the dataset
-await expect(datasetItems.length > 30, 'Number of dataset items');
+await expect(datasetItems.length > 30, `Number of dataset items (actual: ${datasetItems.length}, expected: > 30)`);
await expect(validateDataset(datasetItems, ['url', 'pageTitle']), 'Dataset items validation');