/** * E2E tests for selector-based crawler options: * targetSelector – return only the matched element's content * removeSelector – strip matching elements before formatting */ import { describe, it } from 'node:test'; import assert from 'node:assert'; import { crawl, crawlWithHeaders } from '../helpers/client'; describe('targetSelector', () => { it('returns only the targeted element content', async () => { const res = await crawl({ targetSelector: '#main-content', respondWith: 'markdown' }); assert.strictEqual(res.status, 200); const content: string = res.body.data.content; assert.match(content, /Web Crawling Guide|Section One/i); }); it('excludes elements outside the target', async () => { const res = await crawl({ targetSelector: '#main-content', respondWith: 'markdown' }); const content: string = res.body.data.content; assert.doesNotMatch(content, /Related articles sidebar/i); assert.doesNotMatch(content, /Copyright 2024/i); }); it('sidebar unique link is absent when targeting main-content', async () => { const content: string = (await crawl({ targetSelector: '#main-content', respondWith: 'markdown' })).body.data.content; // This href only exists in