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: fix flaky requestHandlerTimeoutSecs test (#3340)

Martin Adámek5f33f6566d44
diff --git a/test/core/crawlers/browser_crawler.test.ts b/test/core/crawlers/browser_crawler.test.ts
index ab5b51ca0..7bf2e044c 100644
--- a/test/core/crawlers/browser_crawler.test.ts
+++ b/test/core/crawlers/browser_crawler.test.ts
@@ -427,6 +427,7 @@ describe('BrowserCrawler', () => {
await localStorageEmulator.init();
const puppeteerPlugin = new PuppeteerPlugin(puppeteer);
+ vitest.useFakeTimers({ shouldAdvanceTime: true });
try {
const requestList = await RequestList.open({
sources: [{ url: `${serverAddress}/?q=1` }],
@@ -452,6 +453,7 @@ describe('BrowserCrawler', () => {
expect(callSpy).toBeCalledTimes(1);
expect(callSpy).toBeCalledWith('good');
} finally {
+ vitest.useRealTimers();
await localStorageEmulator.destroy();
}
});