mvysny / karibu-testing

Vaadin Server-Side Browserless Containerless Unit Testing
Apache License 2.0
111 stars 14 forks source link

expectNotification not working #165

Closed avdhootu27 closed 6 months ago

avdhootu27 commented 6 months ago

In my code I am showing notification as Notification.show("Done!") but in its test when I test it as expectNotifications("Done!) it says: java.lang.AssertionError: Expected <[Done!]>, actual <[]>. Am i correctly testing it? If yes, why test is not passing?

mvysny commented 6 months ago

That's the correct usage. Could be that expectNotifications() is broken for some Vaadin version. Which Vaadin version are you using please?

avdhootu27 commented 6 months ago

I am using vaadin 14.11.0, karibu-testing-v10-spring 1.3.24

avdhootu27 commented 6 months ago

I just found that if I add MockVaadin.clientRoundtrip() before expectNotifications(), It works.

mvysny commented 6 months ago

Tested with Vaadin 14.11.5, works for me. Please provide a test case or a project which reproduces the issue. Are you sure you haven't reconfigured the TestingLifecycleHook?

avdhootu27 commented 6 months ago

I have reconfigured the TestingLifecycleHook

mvysny commented 6 months ago

Yup, you have to be super-careful when reconfiguring the hook and always call clientRoundtrip(). I've added a kdocumentation in this spirit.