Is it possible to mock the tauri API functions? #10992
Replies: 2 comments
-
I've tried a few more things and I'd like to amend my question to "Is it possible at all to mock the backend in a Selenium/Webdriver environment"? I'll explain the specific case I'm trying to test in case that helps: Instead of opening a tauri dialog to attaching a file, I'd like to return my test file path. It seems to me like I could probably override the 'tauri' command like so:
However, when attempting to use mockIPC from a mocha test suite, I get the error that window is undefined. Is there an officially-supported method to create backend mocks when doing e2e tests in Selenium/Webdriver, or is that reserved specifically for Vitest? The way I see it, there are two courses I can take:
Am I approaching this the correct way? |
Beta Was this translation helpful? Give feedback.
-
I'll close this as I was able to find a different solution. I'm now using keysender for desktop automation and using that to direct the tauri dialogs to my test files. I now have full e2e testing working on my app! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm implementing e2e testing with Selenium and Webdriver (and am grateful to https://github.com/bukowa/tauri-e2e for helping me get started on that), and it's become necessary to mock some file dialog APIs.
I believe the only course of action is to re-implement my own wrappers for tauri_api::dialog and use mockIPC to intercept those, but before I do that I wanted to see if there was a better way.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions