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
There are two scenarios that componentize-go supports for building unit tests:
4
+
-[Basic unit tests](#basic-unit-tests) (Can be run using the wasmtime cli tool)
5
+
-[Guest-Host unit tests](#guest-host-unit-tests) (requires a custom runtime implementation)
6
+
7
+
We recognize that building unit tests with Go and WebAssembly is a bit cumbersome at the moment, so feel free submit a PR or issue if you have feedback and/or improvements.
8
+
9
+
## Basic unit tests
10
+
11
+
These are unit tests that don't require any WIT files and are the easiest to work with. The [wasip2 example](../wasip2/) gives a demonstration for how to do this.
12
+
13
+
## Guest-Host unit tests
14
+
15
+
If tests require guest-host interactions via WIT, the required `//go:wasmexport` and `//go:wasmimport` functions needs to be present in the testfile. To get the [wasip2 example](../wasip2/) to compile, you'll need to append this codeblock to the end of the [handler_test.go file](../wasip2/export_wasi_http_incoming_handler/handler_test.go):
We haven't figured out the best way to run these, so stay tuned or feel free to try creating your own host implementation with wasmtime and see if you can find a way to get these to work!
34
+
35
+
## Mixing Basic and Guest-Host unit tests
36
+
37
+
It is not currently recommended to mix the two types of unit tests in the same package. componentize-go currently has no way of differentiating between the two.
0 commit comments