Skip to content

Commit e04cca5

Browse files
docs: describe the test fakes as ordinary test doubles
Template READMEs said the WASI interfaces are "replaced with fakes", which can read as if a component needs an unusual architecture. Say instead that the tests are plain Hono tests run in Node, that the fakes stand in for external dependencies and aren't imported by src/, and that the built component runs against the real host under wash dev. CONTRIBUTING.md records the same rule for new examples and templates. Signed-off-by: Victor Adossi <vadossi@cosmonic.com>
1 parent 4294294 commit e04cca5

5 files changed

Lines changed: 33 additions & 4 deletions

File tree

‎CONTRIBUTING.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ npm test
143143
- Tests live in each package's `test/` directory and run in Node.
144144
- WASI and wasmCloud interfaces are provided by the host at runtime,
145145
so each package's `vitest.config.ts` resolves them to in-memory fakes in `test/fakes/`.
146+
These are test doubles for external dependencies, as a mocked database client would be elsewhere:
147+
nothing in `src/` imports them,
148+
and a README that mentions them says so,
149+
so that an example or template doesn't suggest a component needs an unusual architecture.
150+
The built component is tested against the real host by the smoke tests below.
146151
- A package keeps its component entry point thin:
147152
the Hono app or handler is in its own module (such as `src/app.ts`) that tests import directly.
148153
Packages built with `tsc` alone, without a bundler, must keep the entry in one module,

‎templates/http-blobstore-handler-hono/README.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,13 @@ npm test
128128
```
129129

130130
Runs the unit tests in `test/` with [vitest](https://vitest.dev/) and reports coverage.
131-
The WASI interfaces the component imports are replaced with fakes in `test/fakes/`.
131+
132+
The tests are ordinary Hono tests:
133+
they run in Node and call `app.request()`, with no Wasm runtime involved.
134+
`wasi:blobstore` is an external dependency, as an object storage client would be in any other service,
135+
so the tests swap it for an in-memory stand-in from `test/fakes/`.
136+
Nothing in `src/` imports the fakes,
137+
and `npm run dev` runs the built component against the real host.
132138

133139
## Build Wasm binary
134140

‎templates/http-handler-hono/README.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,13 @@ npm test
126126
```
127127

128128
Runs the unit tests in `test/` with [vitest](https://vitest.dev/) and reports coverage.
129-
The WASI interfaces the component imports are replaced with fakes in `test/fakes/`.
129+
130+
The tests are ordinary Hono tests:
131+
they run in Node and call `app.request()`, with no Wasm runtime involved.
132+
The one stand-in in `test/fakes/` is for `wasi:http`,
133+
which the host provides and Node can't resolve.
134+
Nothing in `src/` imports it,
135+
and `npm run dev` runs the built component against the real host.
130136

131137
## Build Wasm binary
132138

‎templates/http-kv-handler-hono/README.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,13 @@ npm test
128128
```
129129

130130
Runs the unit tests in `test/` with [vitest](https://vitest.dev/) and reports coverage.
131-
The WASI interfaces the component imports are replaced with fakes in `test/fakes/`.
131+
132+
The tests are ordinary Hono tests:
133+
they run in Node and call `app.request()`, with no Wasm runtime involved.
134+
`wasi:keyvalue` is an external dependency, as a database client would be in any other service,
135+
so the tests swap it for an in-memory stand-in from `test/fakes/`.
136+
Nothing in `src/` imports the fakes,
137+
and `npm run dev` runs the built component against the real host.
132138

133139
## Build Wasm binary
134140

‎templates/http-logging-handler-hono/README.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,13 @@ npm test
9191
```
9292

9393
Runs the unit tests in `test/` with [vitest](https://vitest.dev/) and reports coverage.
94-
The WASI interfaces the component imports are replaced with fakes in `test/fakes/`.
94+
95+
The tests are ordinary Hono tests:
96+
they run in Node and call `app.request()`, with no Wasm runtime involved.
97+
`wasi:logging` is an external dependency, as a logging backend would be in any other service,
98+
so the tests swap it for an in-memory stand-in from `test/fakes/`.
99+
Nothing in `src/` imports the fakes,
100+
and `npm run dev` runs the built component against the real host.
95101

96102
## Build Wasm binary
97103

0 commit comments

Comments
 (0)