joelanman,
@joelanman@hachyderm.io avatar

I'm using Playwright to do end to end testing and very happy with it. How do I now add unit testing? Googling isnt giving very useful results. I'm imagining something like

npm test  

triggering Jest, then Playwright, but they both look for test.js files so that seems not correct?

Can/should Playwright be used for unit testing?

floehopper,
@floehopper@ruby.social avatar

@joelanman In case it helps, I'm successfully using Playwright for browser testing and Jest for unit testing on a SvelteKit app at the moment.

floehopper,
@floehopper@ruby.social avatar

@joelanman I'm using Playwright's testDir config option to limit the tests it runs to a specific directory: https://playwright.dev/docs/api/class-testconfig#test-config-test-dir.

And similarly using the Jest CLI to point at the unit test directory: https://jestjs.io/docs/cli#running-from-the-command-line.

I've wrapped them both up in scripts in package.json and called them from the test script.

joelanman,
@joelanman@hachyderm.io avatar

@floehopper perfect thanks!

llimllib,
@llimllib@hachyderm.io avatar

@joelanman Generally I would say that any test using playwright is an integration test

joelanman,
@joelanman@hachyderm.io avatar

a google got me this, but that says to just use Playwright which doesnt seem right?

https://www.npmjs.com/package/jest-playwright-preset

  • All
  • Subscribed
  • Moderated
  • Favorites
  • programming
  • kavyap
  • thenastyranch
  • Durango
  • DreamBathrooms
  • ngwrru68w68
  • magazineikmin
  • cisconetworking
  • Youngstown
  • mdbf
  • slotface
  • osvaldo12
  • GTA5RPClips
  • rosin
  • InstantRegret
  • provamag3
  • everett
  • cubers
  • vwfavf
  • normalnudes
  • tacticalgear
  • tester
  • ethstaker
  • khanakhh
  • modclub
  • Leos
  • anitta
  • megavids
  • JUstTest
  • All magazines