Test the ascrape_with_js_support method with different browser configurations.
(mock_playwright)
| 144 | |
| 145 | @pytest.mark.asyncio |
| 146 | async def test_ascrape_with_js_support(mock_playwright): |
| 147 | """Test the ascrape_with_js_support method with different browser configurations.""" |
| 148 | mock_pw, mock_browser, mock_context, mock_page = mock_playwright |
| 149 | |
| 150 | url = "http://example.com" |
| 151 | loader = ChromiumLoader([url], backend="playwright", requires_js_support=True) |
| 152 | |
| 153 | # Test with Chromium |
| 154 | await loader.ascrape_with_js_support(url, browser_name="chromium") |
| 155 | assert mock_pw.chromium.launch.call_count == 1 |
| 156 | assert mock_page.goto.call_count == 1 |
| 157 | assert mock_page.content.call_count == 1 |
| 158 | |
| 159 | # Test with Firefox |
| 160 | await loader.ascrape_with_js_support(url, browser_name="firefox") |
| 161 | assert mock_pw.firefox.launch.call_count == 1 |
| 162 | assert mock_page.goto.call_count == 2 |
| 163 | assert mock_page.content.call_count == 2 |
| 164 | |
| 165 | # Test with invalid browser name |
| 166 | with pytest.raises(ValueError): |
| 167 | await loader.ascrape_with_js_support(url, browser_name="invalid") |
| 168 | |
| 169 | |
| 170 | @pytest.mark.asyncio |
nothing calls this directly
no test coverage detected