Skip to content

Commit a16547e

Browse files
committed
test(reactive-rpc): 💍 exit testing process after E2E tests are done
1 parent 4ee7d5c commit a16547e

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,4 @@ jobs:
5959
node-version: ${{ matrix.node-version }}
6060
cache: yarn
6161
- run: yarn install --frozen-lockfile
62-
- run: yarn build:all
63-
- run: PORT=9999 yarn test:reactive-rpc
62+
- run: yarn test:reactive-rpc

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"build": "yarn build:es2020",
4848
"jest": "node -r ts-node/register ./node_modules/.bin/jest",
4949
"test": "jest --maxWorkers 7",
50-
"test:all": "yarn lint && yarn test && yarn test:cli:pointer && yarn test:cli:patch && yarn test:cli:pack && yarn test:reactive-rpc && yarn demo:json-patch && yarn demo:json-pointer",
50+
"test:all": "yarn lint && yarn test && yarn build:all && yarn test:cli:pointer && yarn test:cli:patch && yarn test:cli:pack && yarn test:reactive-rpc && yarn demo:json-patch && yarn demo:json-pointer",
5151
"test:ci": "yarn jest --maxWorkers 3 --no-cache",
5252
"test:cli": "yarn test:cli:pointer && yarn test:cli:patch && yarn test:cli:pack",
5353
"test:cli:pointer": "./bin/json-pointer-test.js ./bin/json-pointer.js",

src/reactive-rpc/common/rpc/__tests__/runApiTests.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {of} from '../../util/of';
44
import {RpcError} from '../caller';
55

66
export interface ApiTestSetupResult {
7-
client: Pick<StreamingRpcClient, 'call$'>;
7+
client: Pick<StreamingRpcClient, 'call$' | 'stop'>;
88
}
99

1010
export type ApiTestSetup = () => ApiTestSetupResult | Promise<ApiTestSetupResult>;
@@ -15,18 +15,21 @@ export const runApiTests = (setup: ApiTestSetup, params: {staticOnly?: boolean}
1515
const {client} = await setup();
1616
const result = await firstValueFrom(client.call$('ping', {}));
1717
expect(result).toBe('pong');
18+
await client.stop();
1819
}, 15_000);
1920

2021
test('can execute without payload', async () => {
2122
const {client} = await setup();
2223
const result = await firstValueFrom(client.call$('ping', undefined));
2324
expect(result).toBe('pong');
25+
await client.stop();
2426
});
2527

2628
test('can execute with unexpected payload', async () => {
2729
const {client} = await setup();
2830
const result = await firstValueFrom(client.call$('ping', 'VERY_UNEXPECTED'));
2931
expect(result).toBe('pong');
32+
await client.stop();
3033
});
3134
});
3235

@@ -35,6 +38,7 @@ export const runApiTests = (setup: ApiTestSetup, params: {staticOnly?: boolean}
3538
const {client} = await setup();
3639
const result = await firstValueFrom(client.call$('double', {num: 1.2}));
3740
expect(result).toEqual({num: 2.4});
41+
await client.stop();
3842
});
3943

4044
test('can execute two request in parallel', async () => {
@@ -44,13 +48,15 @@ export const runApiTests = (setup: ApiTestSetup, params: {staticOnly?: boolean}
4448
const [res1, res2] = await Promise.all([promise1, promise2]);
4549
expect(res1[0]).toEqual({num: 2});
4650
expect(res2[0]).toEqual({num: 4});
51+
await client.stop();
4752
});
4853

4954
test('throws error when validation fails', async () => {
5055
const {client} = await setup();
5156
const [, error] = await of(firstValueFrom(client.call$('double', {num: {}})));
5257
expect((error as RpcError).code).toBe('BAD_REQUEST');
5358
expect((error as RpcError).message).toBe('Payload .num field missing.');
59+
await client.stop();
5460
});
5561
});
5662

@@ -59,6 +65,7 @@ export const runApiTests = (setup: ApiTestSetup, params: {staticOnly?: boolean}
5965
const {client} = await setup();
6066
const [, error] = await of(firstValueFrom(client.call$('error', {})));
6167
expect(error).toMatchObject({message: 'this promise can throw'});
68+
await client.stop();
6269
});
6370
});
6471

@@ -67,6 +74,7 @@ export const runApiTests = (setup: ApiTestSetup, params: {staticOnly?: boolean}
6774
const {client} = await setup();
6875
const [, error] = await of(lastValueFrom(client.call$('streamError', {})));
6976
expect(error).toMatchObject({message: 'Stream always errors'});
77+
await client.stop();
7078
});
7179
});
7280

@@ -79,6 +87,7 @@ export const runApiTests = (setup: ApiTestSetup, params: {staticOnly?: boolean}
7987
commit: 'AAAAAAAAAAAAAAAAAAA',
8088
sha1: 'BBBBBBBBBBBBBBBBBBB',
8189
});
90+
await client.stop();
8291
});
8392
});
8493

@@ -89,6 +98,7 @@ export const runApiTests = (setup: ApiTestSetup, params: {staticOnly?: boolean}
8998
expect(result).toEqual({
9099
bar: 'aa',
91100
});
101+
await client.stop();
92102
});
93103

94104
test('throws on invalid data', async () => {
@@ -97,6 +107,7 @@ export const runApiTests = (setup: ApiTestSetup, params: {staticOnly?: boolean}
97107
expect(error).toMatchObject({
98108
message: '"foo" property missing.',
99109
});
110+
await client.stop();
100111
});
101112
});
102113

@@ -110,6 +121,7 @@ export const runApiTests = (setup: ApiTestSetup, params: {staticOnly?: boolean}
110121
expect(result).toEqual({
111122
bar: 'aa',
112123
});
124+
await client.stop();
113125
});
114126

115127
test('throws on invalid data', async () => {
@@ -118,6 +130,7 @@ export const runApiTests = (setup: ApiTestSetup, params: {staticOnly?: boolean}
118130
expect(error).toMatchObject({
119131
message: '"foo" property missing.',
120132
});
133+
await client.stop();
121134
});
122135
});
123136
}

src/reactive-rpc/common/rpc/client/FetchRpcClient.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,6 @@ export class FetchRpcClient implements RpcClient {
5959
public notify(method: string, data: undefined | unknown): void {
6060
this.notify(method, data);
6161
}
62+
63+
public stop() {}
6264
}

0 commit comments

Comments
 (0)