I am using MuiPickersUtilsProvider
from @material-ui/pickers@
v-3.2.10
and using like followings:
import DateFnsUtils from '@date-io/date-fns'
import { DateTimePicker, MuiPickersUtilsProvider } from '@material-ui/pickers'
<MuiPickersUtilsProvider utils={DateFnsUtils}>
<DateTimePicker .../>
</MuiPickersUtilsProvider>
It works on UI but while running test case it throws error as follows:
TypeError: Utils is not a constructor
But as soon as I use import * as DateFnsUtils from '@date-io/date-fns'
our test case works but same error comes on UI,
And When I use import {default as DateFnsUtils} from '@date-io/date-fns'
our test case works but same error comes on both place(UI and test case)
I found similar discussion on below link but no help
material-ui-pickers/issues/805
// setup file
var enzyme = require('enzyme');
var Adapter = require('enzyme-adapter-react-16');
require('jest-canvas-mock')
enzyme.configure({ adapter: new Adapter() });
crypto = require('@trust/webcrypto')
// fetch undefined
const fetchPolifill = require('whatwg-fetch')
global.fetch = fetchPolifill.fetch
global.Request = fetchPolifill.Request
global.Headers = fetchPolifill.Headers
global.Response = fetchPolifill.Response
function noOp () { }
if (typeof window.URL.createObjectURL === 'undefined') {
Object.defineProperty(window.URL, 'createObjectURL', { value: noOp})
}
I got the same issue and I resolved by following code,