svelte-testing-library icon indicating copy to clipboard operation
svelte-testing-library copied to clipboard

`disabled` property is not set

Open pontakornth opened this issue 2 years ago • 0 comments

For some reason, disabled prop does not seem to set in testing. It is missing.

How to re-produce

  1. Setup a component (named DisabledButton.svelte)
    <button disabled>Disabled</button>
    
  2. Write this test
    import DisableButton from './DisableButton.svelte';
    import '@testing-library/jest-dom';
    import { render, screen } from '@testing-library/svelte';
    describe('DisableButton', () => {
        it('is disabled', () => {
     	   render(DisableButton);
     	   screen.debug();
     	   expect(screen.getByRole('button').hasAttribute('disabled')).toBeTruthy();
        });
    });
    

Expected behavior

The test passes.

Actual behavior

It fails and debug function prints button without disabled prop.

I think it maybe either a bug or something is wrong in my setup.

pontakornth avatar May 31 '22 08:05 pontakornth