tauri-apps / tauri-apps/tauri-docs
docs improvements for test module
Nobody has claimed this yet.
- Dominant language
- MDX
- Stars
- 1.1k
- Forks
- 887
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 48
Description
Describe the bug
I'm trying to write some tests for the Rust backend. In those tests I'm trying to create instances of a mock api so I can tests the bindings to JS are properly setup:
#[cfg(test)]
mod tests {
use super::*;
use std::fs;
use std::path::Path;
fn setup<R: tauri::Runtime>(
builder: tauri::Builder<R>,
) -> Result<tauri::App<R>, std::io::Error> {
let app = builder
.plugin(super::init())
.build(tauri::generate_context!())
.unwrap();
...
Ok(app)
}
#[test]
fn should_drop_model() {
let app = setup(tauri::test::mock_builder()).unwrap();
let app_data_dir = app.handle().path_resolver().app_data_dir().unwrap();
...
}
#[test]
fn should_drop_model2() {
let app = setup(tauri::test::mock_builder()).unwrap();
let app_data_dir = app.handle().path_resolver().app_data_dir().unwrap();
...
}
}
However, whenever I try to run my tests I get the following error:
error: symbol `_EMBED_INFO_PLIST` is already defined
--> src/nebula/nebula.rs:352:20
|
352 | .build(tauri::generate_context!())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `$crate::embed_info_plist_bytes` which comes from the expansion of the macro `tauri::generate_context` (in Nightly builds, run with -Z macro-backtrace for more info)
There is not a lot of documentation on how to achieve this but I can assume that creating multiple instances of a tauri app is not supported?
Reproduction
No response
Expected behavior
No response
Full tauri info output
~/Developer/pulsar (osp/vss*) » yarn tauri info 130 ↵ osp@Oscars-MBP
[✔] Environment
- OS: Mac OS 14.4.1 X64
✔ Xcode Command Line Tools: installed
✔ rustc: 1.77.2 (25ef9e3d8 2024-04-09)
✔ cargo: 1.77.2 (e52e36006 2024-03-26)
✔ rustup: 1.27.0 (bbb9276d2 2024-03-08)
✔ Rust toolchain: stable-aarch64-apple-darwin (default)
- node: 18.20.2
- yarn: 4.1.0
- npm: 10.5.0
[-] Packages
- tauri [RUST]: 1.6.2
- tauri-build [RUST]: 1.5.1
- wry [RUST]: 0.24.7
- tao [RUST]: 0.16.8
- @tauri-apps/api [NPM]: 1.5.3 (outdated, latest: 1.5.4)
- @tauri-apps/cli [NPM]: 1.5.11 (outdated, latest: 1.5.12)
[-] App
- build-type: bundle
- CSP: asset:
- distDir: ../dist
- devPath: http://localhost:1420/
- framework: React
- bundler: Vite
Stack trace
No response
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the test setup in src/nebula/nebula.rs around line 352, especially tauri::test::mock_builder and tauri::generate_context!, then review the existing testing documentation. Document whether multiple mock Tauri app instances are supported, explain the _EMBED_INFO_PLIST error, and make the supported test setup clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation, testing
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100