为什么测试运行器缺少插件?

时间:2021-05-25 15:38:32

标签: testing

我正在使用 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
};

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

想通了!

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

相关问题