I've been experimenting with Test Runner for running tests and attempting to utilize the sendKeys function.
Below is the test code, similar to what is provided on the website:
import { sendKeys } from '@web/test-runner-commands';
it('Sample test from test-runner', async () => {
const input1 = document.createElement('input');
const input2 = document.createElement('input');
document.body.append(input1, input2);
input1.focus();
expect(document.activeElement).to.equal(input1);
await sendKeys({
press: 'Tab',
});
expect(document.activeElement).to.equal(input2);
input1.remove();
input2.remove();
});
The error message I'm encountering is:
Error: Error while executing command send-keys with payload {"press":"Tab"}: Unknown command send-keys. Did you install a plugin to handle this command?
I've tried various configurations to resolve this issue, including using @web/test-runner-chrome
, -puppeteer
, and -playwright
.
Here is a snippet from my web-test-runner.config.mjs
file:
import { esbuildPlugin } from '@web/dev-server-esbuild';
import { chromeLauncher } from '@web/test-runner';
export default {
browsers: [chromeLauncher({ launchOptions: { args: ['--no-sandbox'] } })],
coverage: true,
nodeResolve: true,
plugins: [esbuildPlugin({ ts: true })], // required for TS support
};
Any assistance on resolving this issue would be greatly appreciated.