Files
zeekay 05606477a5 State a version once
A version written into a manifest is written into every manifest that wants it,
which is how eslint came to exist in a hundred and four forms across this estate
and how a package came to resolve twice at run time. The catalog moves the number
out of the manifest: a manifest names the package, the workspace names the
version.

Four are held below their latest because the newer release cannot be used, and
the reason is recorded rather than the version alone: @noble/hashes 2 renamed
every subpath the web3 stack imports, @splinetool/runtime 2 depends on a package
that was never published, @dynamic-labs 5.4.1 the same, and react-resizable-panels
3 points its types condition at the bundle.
2026-08-29 18:13:49 -07:00
..
2019-12-13 07:37:37 +00:00
2026-08-29 18:13:49 -07:00
2019-12-13 07:37:37 +00:00

@improbable-eng/grpc-web-fake-transport

Fake Transport for use with @improbable-eng/grpc-web.

Usage

FakeTransportBuilder builds a Transport that can be configured to send preset headers, messages, and trailers for testing.

By default the Transport that FakeTranportBuilder.build() generates will trigger all of the specified response behaviours (.withHeaders(metadata), .withMessages([msgOne, msgTwo]), .withTrailers(metadata)) when the client has finished sending.

This is usually the desired flow as all of the response behaviour is triggered only after the client has finished sending as would most commonly occur in production usage.

However, in the case of bi-directional or other complex usage it can be helpful to use .withManualTrigger() to disable automatic sending of messages or headers/trailers and trigger the sending manually using sendHeaders(), sendMessages() and sendTrailers().

With Service Stubs generated by ts-protoc-gen

import { FakeTransportBuilder } from '@improbable-eng/grpc-web-fake-transport';

const fakeTransport = new FakeTransportBuilder()
  .withMessages([ new PingResponse() ])
  .build();

const client = new PingServiceClient("https://example.com", {
  transport: fakeTransport
});

client.DoPing(/* ... */);

With grpc-web

import { grpc } from '@improbable-eng/grpc-web';
import { FakeTransportBuilder } from '@improbable-eng/grpc-web-fake-transport';

const fakeTransport = new FakeTransportBuilder()
  .withMessages([ new PingResponse() ])
  .build();

grpc.invoke(PingService.DoPing, {
  host: "https://example.com",
  transport: fakeTransport,
  /* ... */
});

With withManualTrigger()

import { grpc } from '@improbable-eng/grpc-web';
import { FakeTransportBuilder } from '@improbable-eng/grpc-web-fake-transport';

const fakeTransport = new FakeTransportBuilder()
  .withManualTrigger()
  .withHeaders(new grpc.Metadata({ headerKey: "value" }))
  .withMessages([ new PingResponse() ])
  .withTrailers(new grpc.Metadata({ trailerKey: "value" }))
  .build();

grpc.invoke(PingService.DoPing, {
  host: "https://example.com",
  transport: fakeTransport,
  /* ... */
});

// Manually trigger the response behaviours
fakeTransport.sendHeaders();
fakeTransport.sendMessages();
fakeTransport.sendTrailers();

Alternatively replace the Default Transport when initialising your tests:

import { grpc } from "@improbable-eng/grpc-web";
import { NodeHttpTransport } from "@improbable-eng/grpc-web-fake-transport";

// Do this first, before you make any grpc requests!
grpc.setDefaultTransport(fakeTransport);