Skip to content

Use Playwright to run JS tests#37322

Draft
AmitPhulera wants to merge 15 commits intomasterfrom
ap/use-playwright
Draft

Use Playwright to run JS tests#37322
AmitPhulera wants to merge 15 commits intomasterfrom
ap/use-playwright

Conversation

@AmitPhulera
Copy link
Contributor

Product Description

This is a result of my musings with Cursor, grunt and related packages are no longer maintained and we have been keeping them around despite various CVEs.

Grunt was just the test runner, the tests are written using mocha. So swapping the runner should not involve updating testing and just config changes should suffice.

So I decided to create a POC from Cursor to see extent of work that would go into switching it to playwright. The output was promising on my local system and the config switch made it work.

I am opening this PR for tests, this is still WIP and would require further cleanup to make it reviewable.

You are welcome to share your thoughts/ideas on the PR but I might restructure the commits in future.

Feature Flag

Safety Assurance

Safety story

Tests only

Automated test coverage

  • This PR can be reverted after deploy with no further considerations

Labels & Review

  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

- Added Playwright as a development dependency in package.json.
- Created a new Playwright configuration file (playwright.config.js).
- Implemented a Mocha test runner using Playwright in a new file (mocha-runner.spec.js).
- Updated yarn.lock to include Playwright dependencies.
@dimagimon dimagimon added the dependencies Pull requests that update a dependency file label Feb 6, 2026
@AmitPhulera AmitPhulera added the product/invisible Change has no end-user visible impact label Feb 6, 2026
@dimagimon dimagimon added the Risk: Medium Change affects files that have been flagged as medium risk. label Feb 6, 2026
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than adding yet another directory at the top level of this repo, can JS build and artifacts (also thinking of webpack) be moved into a common directory? Maybe that's more disruptive than you'd want in this PR? I'd be find with a follow-up PR that consolidates JS build artifacts into a single directory.

Related thougths

  • The easiest thing might be to move all JS build artifacts into webpack, even though they're not all related to webpack.
  • More disruptive, but probably better organizationally would be to move webpack and playwrite scripts into a new directory. Name suggestion: js-build

// Get the full test title (includes parent describe blocks)
let title = '';
if (titleEl) {
// Remove the duration span from the title
Copy link
Contributor

Choose a reason for hiding this comment

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

This and many others in this file look like AI comments. Are they necessary?

'hqwebapp/bootstrap3',
'hqwebapp/bootstrap5',
'hqwebapp/components',
'case_importer',
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this list need to be updated every time a new app is added? How will people who don't know about this file know to do that?

Edit: I see this list existed before, so it's not a new problem. I still don't love it and wish we had some automated way to calculate the list.

Comment on lines 3 to 6
echo "Before running, please confirm:
grunt is installed via npm or yarn
playwright is installed (npx playwright install chromium)
local development server is active\n"
read -p "Do you want to proceed? (y/n) " proceed
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this check and only echo/prompt for input if playwrite is not found on the path (using which playwrite or something along those lines)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can this file be put in the proposed js-build directory rather than in the repo root?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file product/invisible Change has no end-user visible impact Risk: Medium Change affects files that have been flagged as medium risk.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants