Test
Test:Unit
Writing
Tests can be found here
There's two ways of instantiating an express server for testing.
- Pass in the express server engine
- you want to do this when you want to test methods from the DEngineClient 1
- example engine.spec
await runEngineTestV5( async () => { ... }, { createEngine: createEngineFromServer, } );
- Standup express server as an API endpoint
-
do this when you need to test an API that falls outside of the scope of DEngineClient 1
-
example: workspace.spec
import { createServer, runEngineTestV5 } from "../../engine"; test("ok: basic", async () => { await runEngineTestV5( async ({ wsRoot, vaults, engine }) => { // this creates the server const { port } = await createServer({ wsRoot, vaults }); const payload = { uri: wsRoot, config: { vaults, }, }; // creates an API client const api = new DendronAPI({ endpoint: APIUtils.getLocalEndpoint(port), apiPath: "api", }); // calls the corresponding API let resp = await api.workspaceInit(payload); ... }, { expect } ); });
Executing
Test:Integration
Writing
Executing
Footnotes
Backlinks