on playwright firefox, sendmouse is flaky with concurrency > 1
Hi!
By default, concurrency is set to something higher than two. On Firefox, running identical test files that use sendMouse will fail.
Here's a quick sample with a file called file1.test.js
import { assert } from '@esm-bundle/chai';
import { resetMouse, sendMouse } from '@web/test-runner-commands';
/**
* @param {string} fromString
* @param {boolean} appendToDOM
* @return {HTMLElement}
*/
export function makeFromString(fromString, appendToDOM = true) {
const fragment = document.createRange().createContextualFragment(fromString);
const { firstElementChild } = fragment;
if (appendToDOM) {
document.body.append(fragment);
}
// @ts-ignore Skip cast
return firstElementChild;
}
/**
* @param {HTMLElement} element
*/
function getMiddleOfElement(element) {
const { x, y, width, height } = element.getBoundingClientRect();
return {
x: Math.floor(x + window.pageXOffset + width / 2),
y: Math.floor(y + window.pageYOffset + height / 2),
};
}
describe('sanity test', () => {
beforeEach(() => document.body.replaceChildren());
it('should hover element', async () => {
const element = makeFromString('<div style="min-width:40px;min-height:40px"></div>'.trim());
const { x, y } = getMiddleOfElement(element);
await sendMouse({ type: 'move', position: [x, y] });
const hovered = element.matches(':hover');
await resetMouse();
assert.isTrue(hovered);
});
});
cp file1.test.js file2.test.js npx web-test-runner "./*.test.js" --node-resolve --playwright --browsers firefox --concurrency 2
Tests will fail
npx web-test-runner "./*.test.js" --node-resolve --playwright --browsers firefox --concurrency 1
Will not fail.
can confirm this. Our Firefox tests are failing until concurrency is set to 1.
I'm fairly certain this has something to do with newer versions of Playwright as I too am running into this now; when I hadn't previously with Playwright 1.31.0. I've opened https://github.com/microsoft/playwright/issues/27717 to see if we can't get more information.