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 logging in a test

Ondra Urban50522a28d08f
diff --git a/test/cheerio_crawler.js b/test/cheerio_crawler.js
index 7649a9c9d..6e5ef6e99 100644
--- a/test/cheerio_crawler.js
+++ b/test/cheerio_crawler.js
@@ -283,6 +283,7 @@ describe('CheerioCrawler', () => {
});
it('by throwing on unsupported Content-Encoding', async () => {
+ log.setLevel(log.LEVELS.OFF);
const sourceFilePath = path.join(__dirname, 'data', 'sample.html');
let handlePageInvocationCount = 0;
let allErrors = [];
@@ -300,7 +301,7 @@ describe('CheerioCrawler', () => {
const response = fs.createReadStream(sourceFilePath);
response.headers = {
'content-type': 'text/html', // to avoid throwing
- 'content-encoding': 'compress',
+ 'content-encoding': 'bad-encoding',
};
Object.assign(response, responseMock);
@@ -319,8 +320,9 @@ describe('CheerioCrawler', () => {
expect(handlePageInvocationCount).to.be.eql(0);
allErrors.forEach((err) => {
expect(err).to.include('Invalid Content-Encoding header');
- expect(err).to.include('compress');
+ expect(err).to.include('bad-encoding');
});
+ log.setLevel(log.LEVELS.ERROR);
});
});