-
Notifications
You must be signed in to change notification settings - Fork 497
Add a Playwright e2e test #460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Related PR (which has perhaps fallen into some disrepair): #354 |
Thanks for setting this up. My draft PR I'd opened for feedback has been getting pretty moldy. A couple questions about this e2e setup:
Thanks again for working on this, it should help bridge some gaps with testing basic stuff efficiently. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test ran successfully, but only after
- I downloaded the browsers (additional step required beyond just
npm install
) - Launching the inspector (you can't just run
test:e2e
, you have to runstart
thentest:e2e
)
Just thinking about how to handle this in CI. We'd need to use caching to install playwright and browsers only if they aren't cached. And start the server, then wait for it to be up before running the tests.
name: Playwright Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
# Cache Playwright browsers
- name: Cache Playwright browsers
id: cache-playwright
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright # The default Playwright cache path
key: ${{ runner.os }}-playwright-${{ hashFiles('package-lock.json') }} # Cache key based on OS and package-lock.json
restore-keys: |
${{ runner.os }}-playwright-
- name: Install dependencies
run: npm ci
- name: Install Playwright and browsers unless cached
run: npx playwright install --with-deps
if: steps.cache-playwright.outputs.cache-hit != 'true'
- name: Start Server
run: npm run start
- name: Wait for server to start
run: npx wait-on http://localhost:6274
- name: Run Playwright tests
run: npm run test:e2e
@olaservo: I had been thinking that this would mainly be run in CI but I like to do things in baby steps so that I don't get overwhelmed and so reviewing is easier. My plan was to do the CI in a separate PR. Though now I'm wondering if we should just go for it since @cliffhall points out that it's not trivial to set up the tests locally and a lot of people will simply not bother, so maybe it's not of much use if it's not also run in CI. I probably should look at your PR and see what good stuff I can borrow re: config, timeouts, etc. |
Added |
@msabramo I tried but it failed on format check. Need to run |
so that the CI job can proceed
I added support for https://github.com/daun/playwright-report-summary in cdb9180. As a result, at https://github.com/modelcontextprotocol/inspector/actions/runs/15509171521?pr=460 you can see a nice Playwright test report: |
Write a Playwright test that tests the app end-to-end (e2e).
Motivation and Context
Ensure things don't get broken
How Has This Been Tested?
Breaking Changes
No
Types of changes
Checklist
Additional context