为什么测试运行程序缺少插件



我正在使用TestRunner进行一些测试,并试图让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
};

如有任何帮助,我们将不胜感激。

想明白了!

只需要将"@web/test-runner": "^0.13.1"升级为"@web/test-runner": "^0.13.5"

最新更新