-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
feat: add mock functions for testing and SSG #3437
Conversation
The |
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.
change file :)
nice, thanks 😄 I forget this every time |
@amrbashir maybe you can have a quick look too, to make sure it's what you imagined when we first came up with this |
Yeah this is good; might be worth adding some JsDoc and an example on how/when one might use it.
btw typo here |
True! Good point 👍🏻 I'm writing a thing for the guide rn, but in-code would be cool too.
😄 |
tauri/tooling/api/src/window.ts Lines 1159 to 1166 in 9c50bda
So we either remove that (breaking) or allow both mock functions to override instead to throw errors. |
yeah we discussed this before and we will deprecate (or remove? don't remember) in v2 |
Good to know 👍🏻 What are the reasons for not removing it for v1? If we don't remove it now we will be stuck with it for the next 1 or 2 years (with deprecation and all) 😅 |
it would be the biggest breaking change ever as 90% of tauri users are using it and it was too late to remove at the time. Honestly, I'd like to see it gone in v2 completely but we can discuss it later in v2 beta. |
Hmm okay, so we allow the mock functions to override their properties then? Edit: It would be enough to allow |
fine by me |
let's keep |
[skip ci]
[skip ci]
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
Checklist
fix: remove a typo, closes #___, #___
)Motivation
Allow developers to easier test and SSG their tauri frontends when using the IPC system. This currently requires massive amounts of guarding in if/else statements or mocking the tauri module import outright.
This PR provides two functions
mockIPC
andmockWindows
that allow ergonomic mocking of thewindow.__TAURI_IPC__
andwindow.__TAURI_METADATA__
property respectively.Example
This shows a vitest test.