Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
feat: disable input spellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
jsfez committed Sep 21, 2023
1 parent 5d40cb3 commit 131f2bf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions fixtures/dummy.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ <h3>Image</h3>
<div class="hint">Hint: the image should be loaded.</div>
<img id="image" src="https://placebear.com/500/600" />

<h3>Input</h3>
<div class="hint">Hint: spellcheck should be disabled</div>
<input value="an orrange carrot" autofocus />

<h3>Paragraph</h3>
<div class="hint">
Hint: the font should be loaded and the scrollbar hidden.
Expand Down
10 changes: 9 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ function waitForImagesLoading() {
return allImages.every((img) => img.complete);
}

// Disable spellcheck on all inputs to avoid red underlines
async function disableSpellCheck() {
const inputs = document.querySelectorAll("input");
inputs.forEach((input) => input.setAttribute("spellcheck", "false"));
return true;
}

type LocatorOptions = Parameters<Page["locator"]>[1];

type ScreenshotOptions<
Expand Down Expand Up @@ -78,10 +85,11 @@ export async function argosScreenshot(
// Wait for all busy elements to be loaded
await page.waitForSelector('[aria-busy="true"]', { state: "hidden" });

// Wait for all images and fonts to be loaded
// Code injection to improve the screenshot stability
await Promise.all([
page.waitForFunction(waitForImagesLoading),
page.waitForFunction(waitForFontLoading),
page.waitForFunction(disableSpellCheck),
]);

await handle.screenshot({
Expand Down

0 comments on commit 131f2bf

Please sign in to comment.