I recently rebuilt a moderately sized jQuery application/component using Lit, with the end result being 6-7 components spread over around 2,000 lines of code.

We currently have no automated testing at all but I’d like to implement it, especially now as the markup/styles have been moved into JavaScript. It’s much better overall - but it feels riskier.

But I have no idea where to even begin. Do I set up end to end tests using Playwright on site? Can I test the components individually? Keeping in mind as well that we don’t use a build system/any sort of CI.

Just wanted to get people’s thoughts/experiences here.

  • burtek@programming.dev
    link
    fedilink
    English
    arrow-up
    3
    ·
    3 years ago

    I’d go ahead with cypress, both for e2e testing (whole app at once, component integration etc) and component testing (testing components in isolation)

  • dualphasesaber@beehaw.org
    link
    fedilink
    English
    arrow-up
    3
    ·
    3 years ago

    I haven’t used lit for more than testing viability testing where I am, but I’ve had success setting up jest with some vanilla is web components and doing unit testing that way.

  • TMN@programming.dev
    link
    fedilink
    English
    arrow-up
    2
    ·
    3 years ago

    I love Playwright. I’ve had better results (less flakiness) and better DX than with cypress. +1 for Playwright for me. Coupled with a CI that runs the tests and merge / publish only if everythings fine !

  • breadsmasher
    link
    fedilink
    English
    arrow-up
    1
    ·
    3 years ago

    Just from a quick search of Lit documentation, they support any standard test framework

    https://lit.dev/docs/tools/testing/

    I’ve not used Lit (we use react), but conceptually it should be the same. Assuming you’ve followed testable patterns, you should be able to instantiate each component individually and test independently from other components. You can also create tests that run inbrowser automated - load page, interact, assert results

    edit - I highly recommend a CI build system