-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[core] Allows to run tests with different date adapters #5055
Conversation
These are the results for the performance tests:
|
8bd046f
to
62f56ea
Compare
@@ -22,7 +22,7 @@ const WrappedDesktopDateTimePicker = withPickerControls(DesktopDateTimePicker)({ | |||
describe('<DesktopDateTimePicker />', () => { | |||
const { render } = createPickerRenderer({ | |||
clock: 'fake', | |||
clockConfig: adapterToUse.date('2018-01-01T00:00:00.000').getTime(), | |||
clockConfig: new Date('2018-01-01T00:00:00.000'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getTime
is a date-fns method (note date-io), so this line was silently bugging when trying to run tests with another library
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getTime
is a method from Date
: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime
Do you know which error you had when using it?
62f56ea
to
859887a
Compare
test/utils/pickers-utils.tsx
Outdated
let adapter = 'date-fns'; | ||
|
||
// Check if we are in unit tests | ||
if (typeof window === 'undefined') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (typeof window === 'undefined') { | |
if (/jsdom/.test(window.navigator.userAgent)) { |
Should we check for jsdom instead?
When I run yarn test:unit
locally, typeof window === 'undefined'
returns false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was looking for a way to distinguish karma
and unit
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, can we make it work with test:karma
as well?
I guess we will have to pass an env variable in karma.conf.js and will complicate things a bit.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be nice, but for another PR Could be nice to make test pass with other libraries on master
And before that we should make unit test pass with the current code base which not the case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it can be addressed in separate PR
And before that we should make unit test pass with the current code base which not the case
You mean to make unit tests pass with each of the adapters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. For example some tests do not pass because some libraries use uppercase AM/PM
and others use am/pm
A few tests started to fail on |
Probably the What about using |
@alexfauquette let me check it in Safari |
Ok, few observation from me:
I'm not sure why it's failing, but I tend to think it's related to the timezone somehow (maybe related to this? karma-runner/karma-browserstack-launcher#187) Safari 14.1.2 (Mac OS 10.15.7) WARN: 'including inaccessible elements by default'
LOG: 'startDate', Tue Jan 01 2019 00:00:00 GMT+1100 (AEDT)
.
Safari 14.1.2 (Mac OS 10.15.7): Executed 1 of 1438 SUCCESS (1.814 secs / 1.717 secs) |
According to our browserslist we support Safari 14: Line 29 in b5be28e
Same with Supported platforms on MUI website: https://mui.com/material-ui/getting-started/supported-platforms/#browser So I think it's safe to update Safari version in BrowserStack. |
I've run all test in Safari 14 and some Data Grid tests fail:
|
We had some problems in the past with BrowserStack using a different locale on Edge: #1665 (comment) It might be a similar reason here. The date passed to |
It looks like it was a Safari issue, since tests that failed in Safari 13 passed in Safari 14 (but other tests started to fail in Safari 14 😀) |
Allows to test bugs such as #4890 locally for now
to run unit test with a specific adapter, use
yarn test:unit --date-adapter moment
(orluxon
,day-js
,date-fns
)