You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to write a unit test of a function which has a runtime.EventsEmit(*ctxPtr, "progress", 1) inside.
The function is initially called from wails App, so the wails context is easily available, but in the unit test, no app is created.
if I try to run the test giving a basic context.Background(), I got this error:
2024/07/03 16:24:59 cannot call 'github.com/wailsapp/wails/v2/pkg/runtime.EventsEmit': An invalid context was passed. This method requires the specific context given in the lifecycle hooks: https://wails.io/docs/reference/runtime/intro
I have looked at the internal code of wails to understand how it works, but I cannot create any mock of the context because it uses frontend.Events, which is internal, and golang refuses to compile it.
Has someone already got this problem, and did he success to fix it?
How do you write your unit tests for this kind of code?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm trying to write a unit test of a function which has a
runtime.EventsEmit(*ctxPtr, "progress", 1)
inside.The function is initially called from wails App, so the wails context is easily available, but in the unit test, no app is created.
if I try to run the test giving a basic
context.Background()
, I got this error:I have looked at the internal code of wails to understand how it works, but I cannot create any mock of the context because it uses
frontend.Events
, which is internal, and golang refuses to compile it.Has someone already got this problem, and did he success to fix it?
How do you write your unit tests for this kind of code?
Beta Was this translation helpful? Give feedback.
All reactions