Skip to content

Conversation

msabramo
Copy link
Contributor

@msabramo msabramo commented May 28, 2025

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?

abramowi at Marcs-MacBook-Pro-3 in ~/Code/OpenSource/inspector (playwright-test●)
$ npm run test:e2e

> @modelcontextprotocol/[email protected] test:e2e
> npm run test:e2e --workspace=client


> @modelcontextprotocol/[email protected] test:e2e
> playwright test e2e


Running 8 tests using 5 workers
  8 passed (7.9s)

To open last HTML report run:

  npx playwright show-report

Screenshot 2025-06-17 at 9 16 36 PM

Breaking Changes

No

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@msabramo
Copy link
Contributor Author

Related PR (which has perhaps fallen into some disrepair): #354

@olaservo
Copy link
Member

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:

  • Are you thinking these should just be run locally during development? Originally I assumed that we should have these run as part of CI so we're not relying on that. I think it would also be OK to work that in as separate PRs.
  • I'm making a similar assumption with adding Playwright configs - my original PR had some settings for browser, timeouts, etc. which we can add as we need them.
  • How do you think we should approach adding tests for different transports? In my original tests I was duplicating a lot of code.

Thanks again for working on this, it should help bridge some gaps with testing basic stuff efficiently.

Copy link
Member

@cliffhall cliffhall left a 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

  1. I downloaded the browsers (additional step required beyond just npm install)
  2. Launching the inspector (you can't just run test:e2e, you have to run start then test: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 

@msabramo
Copy link
Contributor Author

msabramo commented Jun 4, 2025

@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.

@cliffhall cliffhall added the waiting on submitter Waiting for the submitter to provide more info label Jun 4, 2025
@msabramo
Copy link
Contributor Author

msabramo commented Jun 5, 2025

Added .github/workflows/e2e_tests.yml (from @cliffhall) in 8a8212c. I guess a maintainer needs to approve the workflow to run so we can see how it works?

@cliffhall
Copy link
Member

cliffhall commented Jun 5, 2025

Added .github/workflows/e2e_tests.yml (from @cliffhall) in 8a8212c. I guess a maintainer needs to approve the workflow to run so we can see how it works?

@msabramo I tried but it failed on format check. Need to run prettier-fix to pass CI.

@msabramo
Copy link
Contributor Author

msabramo commented Jun 7, 2025

@msabramo I tried but it failed on format check. Need to run prettier-fix to pass CI.

Done in df4c372.

@msabramo
Copy link
Contributor Author

msabramo commented Jun 7, 2025

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:

Screenshot 2025-06-07 at 8 29 44 AM

@msabramo
Copy link
Contributor Author

msabramo commented Jun 7, 2025

@olaservo @cliffhall

@msabramo
Copy link
Contributor Author

Still got the following after applying d5b4a6e:

Screenshot 2025-06-20 at 11 31 30 AM

@msabramo
Copy link
Contributor Author

Screenshot 2025-06-20 at 11 36 18 AM

@msabramo
Copy link
Contributor Author

msabramo commented Jun 20, 2025

Here's the markdown summary from the GH Actions log, manually pasted here so we can see how it looks:


🎭 Playwright E2E Test Results

12 passed

Details

12 tests across 1 suite
22.3 seconds
d5b4a6e
ℹ️ Test Environment: Ubuntu Latest, Node.js 18
Browsers: Chromium, Firefox

📊 View Detailed HTML Report (download artifacts)


@msabramo
Copy link
Contributor Author

msabramo commented Jun 20, 2025

I wonder if 1ff39f1 caused something to trigger that asked a maintainer to approve execution?

@cliffhall
Copy link
Member

I wonder if 1ff39f1 caused something to trigger that asked a maintainer to approve execution?

Nope. That's why I asked to remove it. It did not help, but could potentially be a risk.

@msabramo
Copy link
Contributor Author

I wonder if 1ff39f1 caused something to trigger that asked a maintainer to approve execution?

Nope. That's why I asked to remove it. It did not help, but could potentially be a risk.

Okay, reverted the two changes in 9ffe63e and 3e28357.

@msabramo
Copy link
Contributor Author

Maybe once it gets merged, the comments will work on builds on main (probably not on PRs in forks, which is probably a good thing).

@cliffhall
Copy link
Member

Maybe once it gets merged, the comments will work on builds on main (probably not on PRs in forks, which is probably a good thing).

Can you also remove the permissions block

@msabramo
Copy link
Contributor Author

msabramo commented Jun 20, 2025

Can you also remove the permissions block

Yup, in 465ee9a.

@cliffhall
Copy link
Member

One last question: Is there a way to get it to stop trying to make the PR comment? It's still reporting that it can't do it.

Screenshot 2025-06-20 at 5 26 20 PM

@msabramo
Copy link
Contributor Author

One last question: Is there a way to get it to stop trying to make the PR comment? It's still reporting that it can't do it.

I think c747fe8 might do the trick. Let's see...

@msabramo
Copy link
Contributor Author

I think c747fe8 might do the trick. Let's see...

Now it skips that step entirely for forks, which I guess is fine.

Screenshot 2025-06-20 at 7 36 41 PM

It might be possible to have it create the report and just not comment, but not sure if it's worth it...

@msabramo
Copy link
Contributor Author

msabramo commented Jun 21, 2025

IMG_6561

IMG_6562

@cliffhall
Copy link
Member

I re-ran the jobs just to see, and it does not produce the failed annotation warning now.

Screenshot 2025-06-23 at 11 33 32 AM

Copy link
Member

@cliffhall cliffhall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

@cliffhall
Copy link
Member

Thanks for hanging in there @msabramo.

@cliffhall cliffhall merged commit 873b838 into modelcontextprotocol:main Jun 23, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants