@syncular/testkit 0.63.0 → 0.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/client.d.ts +3 -0
- package/dist/client.js +6 -4
- package/dist/create-test-sync.d.ts +2 -0
- package/dist/create-test-sync.js +1 -0
- package/package.json +4 -4
- package/src/client.ts +9 -4
- package/src/create-test-sync.ts +3 -0
package/README.md
CHANGED
|
@@ -78,8 +78,10 @@ adds the test-only controls below.
|
|
|
78
78
|
- `syncAll()` — `syncUntilIdle()` on every online client until quiescent.
|
|
79
79
|
- `dispose()` — close every client and the server (idempotent).
|
|
80
80
|
|
|
81
|
-
`overrides` lets a client use a different `actorId
|
|
82
|
-
config (e.g. `{ clientConfig: { onConflict: fn } }`)
|
|
81
|
+
`overrides` lets a client use a different `actorId`, extra `SyncClient`
|
|
82
|
+
config (e.g. `{ clientConfig: { onConflict: fn } }`), or a `profiler` from
|
|
83
|
+
`@syncular/client/dev` that wraps its database, transport, realtime
|
|
84
|
+
connector and `api` ([Profiling your app](https://syncular.dev/tooling-profiler/)).
|
|
83
85
|
|
|
84
86
|
### `TestClient`
|
|
85
87
|
|
package/dist/client.d.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* extends; this loopback honors every flag on it.
|
|
12
12
|
*/
|
|
13
13
|
import { type ClientSchema, SyncClient, type SyncClientConfig } from '@syncular/client';
|
|
14
|
+
import type { SyncProfiler } from '@syncular/client/dev';
|
|
14
15
|
import type { VirtualClock } from './clock.js';
|
|
15
16
|
import { TransportFaults } from './faults.js';
|
|
16
17
|
import type { TestServer } from './server.js';
|
|
@@ -59,6 +60,8 @@ export interface TestClientOptions {
|
|
|
59
60
|
* `onConflict`, `limits`. `database`, `schema`, `clientId`, `now`,
|
|
60
61
|
* `transport`, `segments`, and `realtime` are owned by the kit.
|
|
61
62
|
*/
|
|
63
|
+
/** Wraps the client's database, transport, realtime connector and `api`. */
|
|
64
|
+
readonly profiler?: SyncProfiler | undefined;
|
|
62
65
|
readonly clientConfig?: Partial<Omit<SyncClientConfig, 'database' | 'schema' | 'clientId' | 'now' | 'transport' | 'segments' | 'realtime'>>;
|
|
63
66
|
}
|
|
64
67
|
/**
|
package/dist/client.js
CHANGED
|
@@ -95,16 +95,18 @@ export function buildTestClient(options) {
|
|
|
95
95
|
},
|
|
96
96
|
};
|
|
97
97
|
};
|
|
98
|
-
const
|
|
99
|
-
|
|
98
|
+
const { profiler } = options;
|
|
99
|
+
const unprofiled = new SyncClient({
|
|
100
|
+
database: profiler?.database(db) ?? db,
|
|
100
101
|
schema,
|
|
101
102
|
clientId: id,
|
|
102
103
|
now: () => clock.now(),
|
|
103
|
-
transport,
|
|
104
|
+
transport: profiler?.transport(transport) ?? transport,
|
|
104
105
|
segments,
|
|
105
|
-
realtime,
|
|
106
|
+
realtime: profiler?.realtime(realtime) ?? realtime,
|
|
106
107
|
...options.clientConfig,
|
|
107
108
|
});
|
|
109
|
+
const api = profiler?.client(unprofiled) ?? unprofiled;
|
|
108
110
|
const client = {
|
|
109
111
|
id,
|
|
110
112
|
actorId,
|
|
@@ -49,6 +49,8 @@ export interface TestClientOverrides {
|
|
|
49
49
|
readonly actorId?: string;
|
|
50
50
|
/** Extra `SyncClient` config (e.g. `onConflict`, `limits`). */
|
|
51
51
|
readonly clientConfig?: TestClientOptions['clientConfig'];
|
|
52
|
+
/** A `createSyncProfiler()` from `@syncular/client/dev` for this client. */
|
|
53
|
+
readonly profiler?: TestClientOptions['profiler'];
|
|
52
54
|
}
|
|
53
55
|
export interface TestSync {
|
|
54
56
|
/** The shared virtual clock — server + every client read it. */
|
package/dist/create-test-sync.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syncular/testkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.65.0",
|
|
4
4
|
"description": "Syncular test kit: in-process loopback server + clients for integration scenarios",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Benjamin Kniffler",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"test": "bun test --preload ./test/setup.ts"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@syncular/server": "0.
|
|
68
|
-
"@syncular/client": "0.
|
|
67
|
+
"@syncular/server": "0.65.0",
|
|
68
|
+
"@syncular/client": "0.65.0"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"react": ">=18.0.0"
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@happy-dom/global-registrator": "^20.0.0",
|
|
80
|
-
"@syncular/react": "0.
|
|
80
|
+
"@syncular/react": "0.65.0",
|
|
81
81
|
"@testing-library/react": "^16.1.0",
|
|
82
82
|
"@types/react": "^18.3.0",
|
|
83
83
|
"react": "^18.3.1",
|
package/src/client.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
transportFailed,
|
|
23
23
|
} from '@syncular/client';
|
|
24
24
|
import { BunClientDatabase } from '@syncular/client/bun';
|
|
25
|
+
import type { SyncProfiler } from '@syncular/client/dev';
|
|
25
26
|
import { handleSegmentDownload, handleSyncRequest } from '@syncular/server';
|
|
26
27
|
import type { VirtualClock } from './clock';
|
|
27
28
|
import {
|
|
@@ -82,6 +83,8 @@ export interface TestClientOptions {
|
|
|
82
83
|
* `onConflict`, `limits`. `database`, `schema`, `clientId`, `now`,
|
|
83
84
|
* `transport`, `segments`, and `realtime` are owned by the kit.
|
|
84
85
|
*/
|
|
86
|
+
/** Wraps the client's database, transport, realtime connector and `api`. */
|
|
87
|
+
readonly profiler?: SyncProfiler | undefined;
|
|
85
88
|
readonly clientConfig?: Partial<
|
|
86
89
|
Omit<
|
|
87
90
|
SyncClientConfig,
|
|
@@ -177,16 +180,18 @@ export function buildTestClient(options: TestClientOptions): {
|
|
|
177
180
|
};
|
|
178
181
|
};
|
|
179
182
|
|
|
180
|
-
const
|
|
181
|
-
|
|
183
|
+
const { profiler } = options;
|
|
184
|
+
const unprofiled = new SyncClient({
|
|
185
|
+
database: profiler?.database(db) ?? db,
|
|
182
186
|
schema,
|
|
183
187
|
clientId: id,
|
|
184
188
|
now: () => clock.now(),
|
|
185
|
-
transport,
|
|
189
|
+
transport: profiler?.transport(transport) ?? transport,
|
|
186
190
|
segments,
|
|
187
|
-
realtime,
|
|
191
|
+
realtime: profiler?.realtime(realtime) ?? realtime,
|
|
188
192
|
...options.clientConfig,
|
|
189
193
|
});
|
|
194
|
+
const api = profiler?.client(unprofiled) ?? unprofiled;
|
|
190
195
|
|
|
191
196
|
const client: TestClient = {
|
|
192
197
|
id,
|
package/src/create-test-sync.ts
CHANGED
|
@@ -65,6 +65,8 @@ export interface TestClientOverrides {
|
|
|
65
65
|
readonly actorId?: string;
|
|
66
66
|
/** Extra `SyncClient` config (e.g. `onConflict`, `limits`). */
|
|
67
67
|
readonly clientConfig?: TestClientOptions['clientConfig'];
|
|
68
|
+
/** A `createSyncProfiler()` from `@syncular/client/dev` for this client. */
|
|
69
|
+
readonly profiler?: TestClientOptions['profiler'];
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
export interface TestSync {
|
|
@@ -123,6 +125,7 @@ export async function createTestSync(
|
|
|
123
125
|
clock,
|
|
124
126
|
id: clientId,
|
|
125
127
|
actorId: overrides?.actorId ?? defaultActor,
|
|
128
|
+
profiler: overrides?.profiler,
|
|
126
129
|
...(overrides?.clientConfig !== undefined
|
|
127
130
|
? { clientConfig: overrides.clientConfig }
|
|
128
131
|
: {}),
|