Test that the scrape method uses ascrape_with_js_support when requires_js_support is True.
(monkeypatch)
| 1385 | |
| 1386 | @pytest.mark.asyncio |
| 1387 | async def test_scrape_uses_js_support_flag(monkeypatch): |
| 1388 | """Test that the scrape method uses ascrape_with_js_support when requires_js_support is True.""" |
| 1389 | |
| 1390 | async def dummy_js(url, browser_name="chromium"): |
| 1391 | return f"<html>JS flag content for {url}</html>" |
| 1392 | |
| 1393 | async def dummy_playwright(url, browser_name="chromium"): |
| 1394 | return f"<html>Playwright content for {url}</html>" |
| 1395 | |
| 1396 | urls = ["http://example.com"] |
| 1397 | loader = ChromiumLoader(urls, backend="playwright", requires_js_support=True) |
| 1398 | monkeypatch.setattr(loader, "ascrape_with_js_support", dummy_js) |
| 1399 | monkeypatch.setattr(loader, "ascrape_playwright", dummy_playwright) |
| 1400 | result = await loader.scrape("http://example.com") |
| 1401 | assert "JS flag content" in result |
| 1402 | |
| 1403 | |
| 1404 | @pytest.mark.asyncio |
nothing calls this directly
no test coverage detected