This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-04-27
Channels
- # announcements (9)
- # aws (1)
- # aws-lambda (12)
- # babashka (18)
- # beginners (37)
- # calva (27)
- # clerk (15)
- # clojure (16)
- # clojure-conj (13)
- # clojure-europe (44)
- # clojure-germany (3)
- # clojure-norway (27)
- # clojure-uk (1)
- # cursive (6)
- # data-science (24)
- # datahike (7)
- # datomic (40)
- # fulcro (5)
- # hoplon (33)
- # hyperfiddle (9)
- # introduce-yourself (6)
- # jobs (1)
- # lsp (22)
- # nbb (2)
- # off-topic (15)
- # pathom (37)
- # pedestal (3)
- # polylith (7)
- # portal (1)
- # re-frame (7)
- # releases (1)
- # remote-jobs (1)
- # rewrite-clj (6)
- # sci (1)
- # scittle (1)
- # xtdb (7)
Hi, I’m looking for some pointers from people who have an automated test set-up for a web app that they are happy with. I need to put together an automated suite of functional and unit tests thst will comprehensively test a web app, It would be great if I had a test setup that a) makes it easy to add additional functional/unit tests, and b) can deal with the inherently flaky nature of browser tests in a straightforward way. Any tips/examples of test setups that are working well for people most welcome.
Hi @U02HPS0397S! What is your previous experience in the automation ecosystem? You mention functional/unit/browser tests.
Been a few years on the browser side, but I developed a selenium suite in my time. Our project already has api tests using clojure.test/ring.mock, which are executed on GitHub actions. I also have Datadog synthetic tests that run on deployed systems (staging and production). It’s that selenium-type bit that I’m most curious about where the current state of the art might be, plus any other tips or insights that people might have of course.
Thanks for the context. In the browser tests ecosystem, the new kid on the block is Cypress, https://docs.cypress.io/guides/end-to-end-testing/writing-your-first-end-to-end-test. The developer experience is better than Selenium.
And of course, nothing is for free, there are some limitations: https://docs.cypress.io/guides/references/trade-offs
I.e.
• Cypress is not a general purpose https://docs.cypress.io/guides/references/trade-offs#Automation-restrictions.
• Cypress commands run https://docs.cypress.io/guides/references/trade-offs#Inside-the-browser.
• There will never be support for https://docs.cypress.io/guides/references/trade-offs#Multiple-tabs.
• You cannot use Cypress to drive https://docs.cypress.io/guides/references/trade-offs#Multiple-browsers-open-at-the-same-time.
• Each test is bound to a single superdomain. Cross-origin navigation inside tests can be enabled by using the cy.origin
command. Please read our https://docs.cypress.io/guides/guides/cross-origin-testing.
Also, if you want to test individual components (not setting up the entire stack) you can go the Storybook route: https://storybook.js.org/docs/react/writing-tests/introduction The main features: 1. https://storybook.js.org/docs/react/writing-tests/interaction-testing --- similar to Cypress/Selenium 2. https://storybook.js.org/docs/react/writing-tests/visual-testing --- the KILLER feature ⚠️ Again, nothing is for free, visual regression needs a https://www.chromatic.com/ account, where you have quotas (how many individual snapshots you are comparing per month).
Thanks. I have heard of cypress but not storybook. I’m ok paying a little money if the dev time savings make it a sensible choice.
are you looking to stay primarily in JS, or is this a ClojureScript context?
if so, the three libraries that you can combine to simulate and test against flaky behavior with retry capabilities would be:
• https://github.com/clj-commons/etaoin for webdriver actions and browser automation
• https://github.com/BrunoBonacci/safely for controlled retries of requests and actions
• https://github.com/clojure/test.check to generate sequences of actions with controlled randomness and define higher-level properties that should still hold across failures and retries
I like how easily I could get etaoin
set up and define sequences of browser actions as pure data, but it may be less fully featured than the JS libraries you're considering (nothing even close to visual regressions, for example).
The intent behind the functionality mentioned in this post might be useful https://clojurians.slack.com/archives/C029PTWD3HR/p1681476571721689
There is now also https://playwright.dev/ in the space of cypress. I have seen some people moving over