Skip to content
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

Impossible to customise data-testid #1898

Open
guilhemforey opened this issue Mar 30, 2022 · 0 comments
Open

Impossible to customise data-testid #1898

guilhemforey opened this issue Mar 30, 2022 · 0 comments

Comments

@guilhemforey
Copy link

guilhemforey commented Mar 30, 2022

Expected Behavior

I'd expect to be able to choose my data-testid labels for unit testing, instead of having MUI-datable, a 3rd party library, to define them for me.

Even if I try to define it manually using the setRowProps() option, it gets overwritten by the current default implementation.

A current hack would be to provide a custom row component, which clearly is overkill for a testing label.

Current Behavior

data-testid is currently forced to 'MUIDataTableBodyRow-' + dataIndex (see current implementation)

Feature was added in PR 667 after being first reported in issue #618

Your Environment

Tech Version
Material-UI 5.2.2
MUI-datatables 4.0

image

function foo(data) {
    const columns = [...];
    const options = {

        /**
         * This is ignored and replaced by current
         * default implementation
         */
        setRowProps: () => ({ "data-testid": "CUSTOM-TEST-ID" }),
      };
    
    return (
        <MUIDataTable
            data={data}
            columns={columns}
            options={options}
        />
    );
}
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

1 participant