Sitemap
Kevin FOO

Kevin FOO

A software engineer, a rock climbing, inline skating enthusiast, a husband, a father.

Scaffold Playwright Tests

2 min readJun 16, 2025

I started with Selenium and later with Puppeteer but my favorite of all now is Playwright. I’m assuming we are creating a folder in home directory ~/

To scaffold a Playwright project, run

cd
mkdir playwright-api-tests
cd playwright-api-tests
npm init playwright@latest

If you do not have npm in your macOS, run

brew install node

I’m assuming you have homebrew installed, if not get it from brew.sh . And I’ve chosen these responses during the scaffold.

Press enter or click to view image in full size

I am using Visual Studio Code to edit my tests.

Press enter or click to view image in full size

I prefer to run the tests with UI

npx playwright test --ui
Press enter or click to view image in full size

After clicking the triangle play button, tests will begin and shows its results. If you needed an auth token prior to all your test. You can configure a global-setup.ts that will run before all your tests.

Get Kevin FOO’s stories in your inbox

Join Medium for free to get updates from this writer.

In playwright-api-tests folder, create a file name playwright.config.ts

In playwright-api-tests folder, create a file name global-setup.ts

I have started a local web server listening at 8080.

python3 -m http.server 8080

Although it doesn’t require the JWT token. I am going to put a breakpoint to show that localhost.ts in fact had obtained the JWT token for its tests.

Create `localhost.spec.ts` in `playwright-api-tests/tests` folder

JWT token obtained prior to the test.

Press enter or click to view image in full size

< Back to all the stories I had written

--

--

Kevin FOO
Kevin FOO

Written by Kevin FOO

A software engineer, a rock climbing, inline skating enthusiast, a husband, a father.