Simulate a button click in Jest

前端 未结 6 516
太阳男子
太阳男子 2020-11-30 22:49

Simulating a button click seems like a very easy/standard operation. Yet, I can\'t get it to work in Jest.js tests.

This is what I tried (and also doing it using jQue

6条回答
  •  没有蜡笔的小新
    2020-11-30 23:06

    I needed to do a little bit of testing myself of a button component. These tests work for me ;-)

    import { shallow } from "enzyme";
    import * as React from "react";
    import Button from "../button.component";
    
    describe("Button Component Tests", () => {
        it("Renders correctly in DOM", () => {
            shallow(
                

提交回复
热议问题