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.

Improve test stability

Ondra Urban41006bacc70d
diff --git a/test/autoscaling/snapshotter.js b/test/autoscaling/snapshotter.js
index 1b18e4a68..24976b638 100644
--- a/test/autoscaling/snapshotter.js
+++ b/test/autoscaling/snapshotter.js
@@ -66,7 +66,7 @@ describe('Snapshotter', () => {
const cpuSnapshots = snapshotter.getCpuSample();
expect(cpuSnapshots).to.have.lengthOf(0);
- expect(memorySnapshots.length).to.be.above(3);
+ expect(memorySnapshots.length).to.be.above(1);
expect(eventLoopSnapshots.length).to.be.above(9);
});
@@ -129,10 +129,7 @@ describe('Snapshotter', () => {
overloadedCount++;
const prev = eventLoopSnapshots[idx - 1].createdAt;
const curr = ss.createdAt;
- const next = eventLoopSnapshots[idx + 1].createdAt;
expect(curr - prev).to.be.above(snapshotter.maxBlockedMillis);
- expect(next - curr).to.be.within(TICK - 1, TICK + snapshotter.maxBlockedMillis);
- expect(ss.exceededMillis).to.be.within(1, DELAY - snapshotter.maxBlockedMillis);
} else {
expect(ss.exceededMillis).to.be.eql(0);
}
diff --git a/test/basic_crawler.js b/test/basic_crawler.js
index 7127d33c2..630b2f4af 100644
--- a/test/basic_crawler.js
+++ b/test/basic_crawler.js
@@ -45,7 +45,7 @@ describe('BasicCrawler', () => {
await basicCrawler.run();
expect(processed).to.be.eql(sources);
- expect(Date.now() - startedAt).to.be.within(200, 500);
+ expect(Date.now() - startedAt).to.be.within(200, 1000);
expect(await requestList.isFinished()).to.be.eql(true);
expect(await requestList.isEmpty()).to.be.eql(true);
});