enhancement: Add mock-based unit tests for site extractors #21
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent: #4
Description
The core library has good test coverage (cookiejar, cookies_txt, nodes, readability, close, article all have tests), but the site extractors have no tests that can run without a live browser:
sites/duckduckgo/duckduckgo_test.go— needs verification (likely requires browser)sites/google/google_test.go— needs verificationsites/powerball/powerball_test.go— needs verificationsites/megamillions/megamillions_test.go— needs verificationsites/wegmans/wegmans_test.go— needs verificationsites/aislegopher/aislegopher_test.go— needs verificationsites/archive/archive_test.go— needs verificationsites/useragents/useragents_test.go— needs verificationThe existing
mockDocumentandmockNodeinmock_test.goandnodes_test.goprovide a pattern for testing without Playwright.Proposal
For each site extractor, create test cases that:
mockDocumentwith pre-built HTML matching the expected page structureThis would catch regressions when sites change their HTML structure.
Starting work on this. Plan: create exported
extractortestpackage withMockBrowser,MockDocument, andMockNodethat support selector-based responses. Write fixture-based tests for DuckDuckGo and Powerball extractors to establish the pattern.Work finished — created
extractortestpackage with exportedMockBrowser,MockDocument,MockNodesupporting selector-based responses. Added extraction tests for DuckDuckGo and Powerball. Merged in PR #43.