Skip to content

Commit 45467e6

Browse files
feat(testing): make address of test server public (#1819)
1 parent 7b0224a commit 45467e6

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

packages/test/src/test-ephemeral-server.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,14 @@ test("TestEnvironment doesn't hang on fail to download", async (t) => {
147147
t.pass();
148148
}
149149
});
150+
151+
test('TestEnvironment.createLocal correctly populates address', async (t) => {
152+
const testEnv = await RealTestWorkflowEnvironment.createLocal();
153+
t.teardown(() => testEnv.teardown());
154+
await t.notThrowsAsync(async () => {
155+
await Connection.connect({
156+
address: testEnv.address,
157+
connectTimeout: 500,
158+
});
159+
}, 'should be able to connect to test server');
160+
});

packages/testing/src/testing-workflow-environment.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ export class TestWorkflowEnvironment {
9090
protected readonly server: native.EphemeralServer | 'existing',
9191
connection: Connection,
9292
nativeConnection: NativeConnection,
93-
namespace: string | undefined
93+
namespace: string | undefined,
94+
/**
95+
* Address used when constructing `connection` and `nativeConnection`
96+
*/
97+
public readonly address: string
9498
) {
9599
this.connection = connection;
96100
this.nativeConnection = nativeConnection;
@@ -238,7 +242,16 @@ export class TestWorkflowEnvironment {
238242
[InternalConnectionOptionsSymbol]: { supportsTestService: supportsTimeSkipping },
239243
});
240244

241-
return new this(runtime, optsWithDefaults, supportsTimeSkipping, server, connection, nativeConnection, namespace);
245+
return new this(
246+
runtime,
247+
optsWithDefaults,
248+
supportsTimeSkipping,
249+
server,
250+
connection,
251+
nativeConnection,
252+
namespace,
253+
address
254+
);
242255
}
243256

244257
/**

0 commit comments

Comments
 (0)