How to instantiate DatePicker in JUnit

I’ve tried the following:

DatePicker date = new DatePicker();

This throws a null pointer exception. From looking at the DatePicker class, I can see that if no arguments are passed into the DatePicker constructor, then the LocalDate member variable gets set to null. I’ve also tried the following, but it still produces a null pointer exception.

DatePicker date = new DatePicker(LocalDate.now());

Any ideas on how I could fix this? I don’t actually want to create a DaterPicker inside my JUnit test, but I’m creating an object that does, which leads to a null pointer exception. The examples above are just minimal working examples.

I’ve gone through https://vaadin.com/learn/tutorials/junit5, but it hasn’t yet helped me fix the problem.