gregnb / mui-datatables

Datatables for React using Material-UI
MIT License
2.71k stars 932 forks source link

Jest snapshot testing fails with material-ui/core 4.10.1 or 4.10.2 #1367

Open bbourn opened 4 years ago

bbourn commented 4 years ago

Expected Behavior

Jest snapshots stay the same when no code changes.

Current Behavior

Snapshots now get a mui-id: field that changes

Steps to Reproduce (for bugs)

We use jest and mui-datatables 3.1.1.

My jest snapshot tests are failing the mui-datatables with 4.10.1 or 4.10.2 but NOT 4.10.0

I am hoping I can describe high level what is happening and either here or the material-ui/core folks will 'just know' what I am talking about... I am sure it will be 'fixed' downstream one way or another so this might serve as a QA post;

My test passes.

Upgrade from 4.10.0 to 4.10.2. (No '^' in package-lock.json so change version and run yarn install)

Now snapshot fail includes an 'id' field it did not have before.

               <input
-                 type="hidden"
+                 aria-hidden="true"
+                 class="MuiSelect-nativeInput"
+                 tabindex="-1"
                  value="0"
                />
                <svg
                  aria-hidden="true"
                  class="MuiSvgIcon-root MuiSelect-icon"
@@ -554,19 +556,20 @@
                      <div
                        class="MuiTablePagination-spacer"
                      />
                      <p
                        class="MuiTypography-root MuiTablePagination-caption MuiTypography-body2 MuiTypography-colorInherit"
+                       id="mui-53511"
                      >
                        Rows per page:
                      </p>
                      <div
                        class="MuiInputBase-root MuiTablePagination-input MuiTablePagination-selectRoot"
                      >
                        <select
-                         aria-label="Rows per page:"
                          class="MuiSelect-root MuiSelect-select MuiTablePagination-select MuiInputBase-input"
+                         id="mui-86667"
                        >

And that 'id' changes every test after:

                      class="MuiSelect-root MuiSelect-select MuiTablePagination-select MuiInputBase-input"
-                         id="mui-40652"
+                         id="mui-10525"
patorjk commented 4 years ago

If the tests work with v4.10.0 but not 4.10.1 or 4.10.2, then this sounds like a material-ui issue. The footer of this table doesn't attach IDs that look like that, so I'm guessing this something that got introduced into the main library recently.

bbourn commented 4 years ago

Yes. Appears so.

https://github.com/mui-org/material-ui/issues/21293

albertocorrales commented 4 years ago

I hit the same issue with material-ui/core package, version 4.11.0. Version 4.9.14 works well and it doesn't break our jest snapshot tests

harryp-art commented 3 years ago

@albertocorrales hi, i did that but i am still getting this error: You should useimport { alpha } from '@material-ui/core/styles'``

NataliaAgarkova commented 1 year ago

I have the same issue in material-core 4.8.2