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.

fixed tests

Petr Patekfd49fdf300db
diff --git a/src/session_pool/session.js b/src/session_pool/session.js
index 897836caa..c3407bc76 100644
--- a/src/session_pool/session.js
+++ b/src/session_pool/session.js
@@ -226,7 +226,7 @@ export class Session {
* @param url {String}
*/
setCookies(cookies, url) {
- const isPuppeteerCookies = !!cookies[0].name;
+ const isPuppeteerCookies = !!cookies[0] && !!cookies[0].name;
for (const cookie of cookies) {
let cookieToSave;
diff --git a/test/session_pool/session.test.js b/test/session_pool/session.test.js
index ac350fa81..85df444e7 100644
--- a/test/session_pool/session.test.js
+++ b/test/session_pool/session.test.js
@@ -70,7 +70,7 @@ describe('Session - testing session behaviour ', () => {
let error;
try {
- session.putResponse({ headers: { Cookie: 'invaldi*{*{*{*-----***@s' } });
+ session.setCookiesFromResponse({ headers: { Cookie: 'invaldi*{*{*{*-----***@s' } });
} catch (e) {
error = e;
}