4 ms·
With the BeautifulSoup tests I can run 1000s of tests in seconds. Cypress/Playwright are wonderful for e2e tests, but not comparable to simple unit tests you'd
by jilles 2y ago
With the BeautifulSoup tests I can run 1000s of tests in seconds. Cypress/Playwright are wonderful for e2e tests, but not comparable to simple unit tests you'd have in React/Vue. I find that the BeautifulSoup tests are a decent middle ground.
- luontola 2y agoI've successfully used (for 3+ years in multiple projects) an approach similar to BeautifulSoup's get_text() function to assert the whole visible text of a component. You can implement it in other languages with a few regexes. One addition makes it an order of magnitude more versatile: a way to visualize non-textual information as text in the tests. For example add a data-test-icon attribute which contains the replacement text that should be shown in tests. Another method is to parse the HTML and write custom visualization for some elements, so that you get useful default visualization for at least form elements and such, without having to repeat the data-test-icon attribute every time. See https://martinfowler.com/articles/tdd-html-templates.html#BonusLevelStringlyAsserted https://martinfowler.com/articles/tdd-html-templates.html#Bo...
- wmanley 2y agoI’ve done something similar, but using pandoc to convert the html to text, so tables and bullet points are rendered appropriately.
- azemetre 2y agoWhy is that a good thing when testing a web app? You want to see if the browser is executing your code with the correct intent. Seems very brittle and may not catch actual regressions browsers introduce.
- viraptor 2y agoBut with beautifulsoup you don't test the interactions at all. You only test the rendered template which is nice, but doesn't tell you if any button actually works the way you expect.