我正在使用Test Runner进行一些测试,并尝试让sendKeys函数正常工作。
这是我的测试(来自网站的相同代码):
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();
});我一直收到的错误:
Error: Error while executing command send-keys with payload {"press":"Tab"}: Unknown command send-keys. Did you install a plugin to handle this command?我已经尝试了所有的设置(@web/test-runner-chrome,-puppeteer和-playwright)来实现这个功能。
这是我的web-test-runner.config.mjs
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
};任何帮助都将深表感谢。
发布于 2021-05-25 23:56:18
想明白了!
只需将"@web/test-runner": "^0.13.1"升级到"@web/test-runner": "^0.13.5"即可。
https://stackoverflow.com/questions/67691254
复制相似问题