我有一个针对stenciljs组件的e2e测试,我想在其中断言提交到表单的值。我得到了一个类似于比赛条件的错误,但我不确定它可能在哪里。我的测试是这样的:
it('TEST THE VAUE of FORM SUBMISSION', async () => {
//arrange
const page = await newE2EPage();
// ---- SET UP REQUEST HANDLER ----
await page.setRequestInterception(true);
page.on('request', (request) => {
if (request.url() === 'http://test.com') {
request.respond({
content: 'application/json',
headers: { 'Access-Control-Allow-Origin': '*' },
status: 200,
body: request.postData(),
});
} else {
request.continue();
}
});
// ---- SET UP FORM ELEMENT ----
await page.setContent(`
<form action="http://test.com" method="POST" >
<sjs-checkbox id="unchecked" name="checked" value="no"></sjs-checkbox>
<sjs-checkbox id="checked" name="checked" value ="yes" checked></sjs-checkbox>
</form>`);
//act
// INVOKE FORM SUBMIT
const response = await page.evaluate(() => {
const form = document.querySelector('form');
form.submit();
});
//assert
expect(await response).toBeDefined();
});
下面是错误消息:
Cannot log after tests are done. Did you forget to wait for something async in your test?
Attempted to log "requestfailed http://localhost:3333/~dev-server".
abds-checkbox ⺠TEST THE VAUE of FORM SUBMISSION
Request is already handled!
同样,这似乎是一个比赛条件,但我不确定在做出断言之前我应该等待什么。
我在用
有人知道如何断言表单的值吗。提交()使用stencil的傀儡e2e测试?