Skip to content

Conversation

@DmitrySharabin
Copy link
Member

@DmitrySharabin DmitrySharabin commented Mar 27, 2025

Uses Playwright under the hood. To keep hTest small, none of the browser binaries are installed by default.

One can run npx playwright install to install all the browsers, or npm install @playwright/browser-chromium, npm install @playwright/browser-firefox, npm install @playwright/browser-webkit to install Chromium, Firefox, or Webkit browser, respectively. We should probably add a note on this in our docs.

On the first run, if no browser binary is downloaded, Playwright will show a friendly message:

image

Down there is a small demo that shows all the tests we have successfully run in a headless browser. Console formatting tests are ignored since they (not dynamically) import the Chalk package, but the browser didn't choke on them. We should probably add a separate message about what tests were ignored and why.

In the video, you can see a (intentionally) falling test from these tests (not in the PR):

export default {
	name: "DOM tests",
	description: "Tests that are supposed to run in a browser",
	tests: [
		{
			run: () => Boolean(document.body),
			expect: true,
		},
		{
			name: "Document title is equal to “Foo”",
			run: () => document.title,
			expect: "Foo",
		},
	],
};
hTest.Run.in.Headless.Browser.mp4

@netlify
Copy link

netlify bot commented Mar 27, 2025

Deploy Preview for h-test ready!

Name Link
🔨 Latest commit 0d086a9
🔍 Latest deploy log https://app.netlify.com/sites/h-test/deploys/67e68fac8b46ed000855dddd
😎 Deploy Preview https://deploy-preview-92--h-test.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@DmitrySharabin DmitrySharabin force-pushed the headless-browser branch 5 times, most recently from 1eb67e5 to 1e3bd67 Compare March 28, 2025 11:28
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.

2 participants