coryhouse / reactjsconsulting

React Related Resources
http://www.reactjsconsulting.com
378 stars 37 forks source link

Playwright #169

Open coryhouse opened 1 year ago

coryhouse commented 1 year ago

Locators can be chained to narrow down the search to a particular part of the page.

Use codegen to quickly write tests

const product = page.getByRole('listitem').filter({ hasText: 'Product 2' });

Set up watch mode to rerun the associated test upon save (this assumes the test file and the test are in the same dir)

Playwright automatically traverses the shadow DOM.

NOTE: If you call expect, but forget to import expect, it will fail the test, but won't tell you why. 🤬

Use project dependencies for running login once

Fail test if there's a console log

npm scripts

"start:codegen": "concurrently npm:start-mocked npm:codegen",
"codegen": "playwright codegen --load-storage=storageState.json http://localhost:3000",