mui-datatables icon indicating copy to clipboard operation
mui-datatables copied to clipboard

Impossible to customise data-testid

Open guilhemforey opened this issue 2 years ago • 0 comments

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}
        />
    );
}

guilhemforey avatar Mar 30 '22 14:03 guilhemforey