pact-bun
v0.0.3
Published
Pact π Contract Testing for Bun π₯, Powered by Rust π¦
Downloads
7
Readme
pact-bun
Pact Contract Testing with Bun
Try out Pact-Bun in your browser, via our interactive tutorial
Pre-Reqs
| OS | Architecture | Supported | | ------- | ------------ | --------- | | OSX | x86_64 | β | | OSX | arm | β | | Linux | x86_64 | β | | Linux | arm | β | | Windows | x86_64 | β |
- Bun only supports Windows via WSL.
- You can use pact-js / deno-pact as alternative TypeScript/JavaScript Pact libraries.
You can install the correct FFI library with the following command.
deno run -A --unstable https://deno.land/x/pact/src/downloadFfi.ts --run
- Checks if it exists in
${HOME}/.pact/ffi/<pact_ffi_version>
- Downloads the necessary library for your architecture
- Executes the library to ensure it works
Installing
In a new project:
bun init
bun add pact-bun
In an new project:
bun add pact-bun
How to get started
bun run helloPactBun.ts
import { PactBun, Pact } from "pact-bun";
const pact = new PactBun();
console.log(pact.getPactFfiVersion());
bun run helloPactBun.ts
Examples
Run an example by
git clone [email protected]:YOU54F/pact-bun.git
cd pact-bun
bun install
bun run <name of test>
gRPC Area Calculator
bun run src/grpc.consumer.test.ts
- The Proto File - area_calculator.proto
- The Client Pact test grpc.consumer.test.ts
HTTP service
bun run src/http.consumer.test.ts
- The Client Pact test http.consumer.test.ts
Pact Verifications
bun run src/verifier.test.ts
- Pact verification task, tests multiple transport protocols verifier.test.ts
Docker
If you want to try out a Pact Broker to publish, view and retrieve your pact files, you can try out this quick start quick.
You'll need docker-compose
.
curl pact.saf.dev -Lso - | bash -s -- broker deploy mybroker 8000