Skip to content

fireEvent click on disabled button fired #208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hxgqh opened this issue Feb 14, 2021 · 7 comments
Closed

fireEvent click on disabled button fired #208

hxgqh opened this issue Feb 14, 2021 · 7 comments

Comments

@hxgqh
Copy link

hxgqh commented Feb 14, 2021

<button disabled="disabled">button</button>
await fireEvent.click(btn);
const clickEvent = emitted().click;
// The following test fail. It SHOULD success.
expect(!!clickEvent).toBe(false);
@afontcu
Copy link
Member

afontcu commented Feb 14, 2021

Hi,

Just ran it locally and it passes, as expected. Maybe your test is failing due to something else?

@afontcu
Copy link
Member

afontcu commented May 8, 2021

Closing as this doesn't look like a library issue. Feel free to reopen if it's not the case! :)

@afontcu afontcu closed this as completed May 8, 2021
@igbominadeveloper
Copy link

I am currently dealing with this issue.

@igbominadeveloper
Copy link

const Component = {
      template: `<button :disabled="disabled" @click="handleClick">Click Me</button>`,
      props: ['disabled'],
      methods: {
        handleClick() {
          this.$emit('save')
        },
      },
    }

    const { getByText, emitted, debug } = render(Component, {
      props: {
        disabled: true,
      },
    })

    const saveButton = getByText('Click Me')
    await fireEvent.click(saveButton)
    expect(emitted('save').length).toBe(0)

@igbominadeveloper
Copy link

The test is failing

@afontcu
Copy link
Member

afontcu commented Aug 30, 2022

Hi,

this is expected (albeit counterintuitive): testing-library/dom-testing-library#217

@trinketmage
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants