最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

reactjs - Cypress fails on uncaught NotFoundError when clicking form submit button - Stack Overflow

programmeradmin1浏览0评论

I'm writing integration tests for my Next.JS application, and it is persistently failing on this test case meant to check the button pressing with no inputs. I anticipated it may be down to the DOM not loading in, or the action not being assigned to the button, but manual testing, and the insertion of the wait() call have no effect on the result.

    describe('login', () => {
      it('has clickable login button', () => {
        cy.visit(domain + "/login")
        cy.wait(10000)
        cy.get("#loginsubmit").click()
      })
    })

Here's the output in the Cypress client of the test.

This is the page on which the error keeps happening.

"use client";

import ...

export default function Login() {
  const [state, action, pending] = useActionState(login, undefined);

  return (
    <section className="...">
      <div className="text-center">
        <span className={title()}>Login</span>
      </div>
      <Form
        action={action}
        className="..."
      >
        ...
        <Button id="loginsubmit" disabled={pending} type="submit">
          Log In
        </Button>
        {state?.errors?.password && <p>{state.errors.password}</p>}
      </Form>
    </section>
  );
}

Any help would be appreciated.

发布评论

评论列表(0)

  1. 暂无评论