matterbridge 3.2.7-dev-20250908-3bb699e → 3.2.7-dev-20250909-10831d3
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/CHANGELOG.md +2 -0
- package/dist/{jest-utils → utils}/jestHelpers.js +73 -15
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,76 @@
|
|
|
1
1
|
import { rmSync } from 'node:fs';
|
|
2
2
|
import { inspect } from 'node:util';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { jest } from '@jest/globals';
|
|
3
5
|
import { DeviceTypeId, Endpoint, Environment, ServerNode, ServerNodeStore, VendorId, LogFormat as MatterLogFormat, LogLevel as MatterLogLevel, Lifecycle } from '@matter/main';
|
|
4
6
|
import { AggregatorEndpoint, RootEndpoint } from '@matter/main/endpoints';
|
|
5
7
|
import { MdnsService } from '@matter/main/protocol';
|
|
8
|
+
import { AnsiLogger } from 'node-ansi-logger';
|
|
9
|
+
export let loggerLogSpy;
|
|
10
|
+
export let consoleLogSpy;
|
|
11
|
+
export let consoleDebugSpy;
|
|
12
|
+
export let consoleInfoSpy;
|
|
13
|
+
export let consoleWarnSpy;
|
|
14
|
+
export let consoleErrorSpy;
|
|
15
|
+
export function setupTest(name, debug = false) {
|
|
16
|
+
expect(name).toBeDefined();
|
|
17
|
+
expect(typeof name).toBe('string');
|
|
18
|
+
expect(name.length).toBeGreaterThanOrEqual(4);
|
|
19
|
+
rmSync(path.join('jest', name), { recursive: true, force: true });
|
|
20
|
+
if (debug) {
|
|
21
|
+
loggerLogSpy = jest.spyOn(AnsiLogger.prototype, 'log');
|
|
22
|
+
consoleLogSpy = jest.spyOn(console, 'log');
|
|
23
|
+
consoleDebugSpy = jest.spyOn(console, 'debug');
|
|
24
|
+
consoleInfoSpy = jest.spyOn(console, 'info');
|
|
25
|
+
consoleWarnSpy = jest.spyOn(console, 'warn');
|
|
26
|
+
consoleErrorSpy = jest.spyOn(console, 'error');
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
loggerLogSpy = jest.spyOn(AnsiLogger.prototype, 'log').mockImplementation(() => { });
|
|
30
|
+
consoleLogSpy = jest.spyOn(console, 'log').mockImplementation(() => { });
|
|
31
|
+
consoleDebugSpy = jest.spyOn(console, 'debug').mockImplementation(() => { });
|
|
32
|
+
consoleInfoSpy = jest.spyOn(console, 'info').mockImplementation(() => { });
|
|
33
|
+
consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation(() => { });
|
|
34
|
+
consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => { });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export function setDebug(debug) {
|
|
38
|
+
if (debug) {
|
|
39
|
+
loggerLogSpy.mockRestore();
|
|
40
|
+
consoleLogSpy.mockRestore();
|
|
41
|
+
consoleDebugSpy.mockRestore();
|
|
42
|
+
consoleInfoSpy.mockRestore();
|
|
43
|
+
consoleWarnSpy.mockRestore();
|
|
44
|
+
consoleErrorSpy.mockRestore();
|
|
45
|
+
loggerLogSpy = jest.spyOn(AnsiLogger.prototype, 'log');
|
|
46
|
+
consoleLogSpy = jest.spyOn(console, 'log');
|
|
47
|
+
consoleDebugSpy = jest.spyOn(console, 'debug');
|
|
48
|
+
consoleInfoSpy = jest.spyOn(console, 'info');
|
|
49
|
+
consoleWarnSpy = jest.spyOn(console, 'warn');
|
|
50
|
+
consoleErrorSpy = jest.spyOn(console, 'error');
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
loggerLogSpy = jest.spyOn(AnsiLogger.prototype, 'log').mockImplementation(() => { });
|
|
54
|
+
consoleLogSpy = jest.spyOn(console, 'log').mockImplementation(() => { });
|
|
55
|
+
consoleDebugSpy = jest.spyOn(console, 'debug').mockImplementation(() => { });
|
|
56
|
+
consoleInfoSpy = jest.spyOn(console, 'info').mockImplementation(() => { });
|
|
57
|
+
consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation(() => { });
|
|
58
|
+
consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => { });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export function createTestEnvironment(homeDir) {
|
|
62
|
+
expect(homeDir).toBeDefined();
|
|
63
|
+
expect(typeof homeDir).toBe('string');
|
|
64
|
+
expect(homeDir.length).toBeGreaterThanOrEqual(4);
|
|
65
|
+
rmSync(homeDir, { recursive: true, force: true });
|
|
66
|
+
const environment = Environment.default;
|
|
67
|
+
environment.vars.set('log.level', MatterLogLevel.DEBUG);
|
|
68
|
+
environment.vars.set('log.format', MatterLogFormat.ANSI);
|
|
69
|
+
environment.vars.set('path.root', homeDir);
|
|
70
|
+
environment.vars.set('runtime.signals', false);
|
|
71
|
+
environment.vars.set('runtime.exitcode', false);
|
|
72
|
+
return environment;
|
|
73
|
+
}
|
|
6
74
|
export async function flushAsync(ticks = 3, microTurns = 10, pause = 100) {
|
|
7
75
|
for (let i = 0; i < ticks; i++)
|
|
8
76
|
await new Promise((resolve) => setImmediate(resolve));
|
|
@@ -46,19 +114,6 @@ export async function assertAllEndpointNumbersPersisted(targetServer) {
|
|
|
46
114
|
}
|
|
47
115
|
return all.length;
|
|
48
116
|
}
|
|
49
|
-
export function createTestEnvironment(homeDir) {
|
|
50
|
-
expect(homeDir).toBeDefined();
|
|
51
|
-
expect(typeof homeDir).toBe('string');
|
|
52
|
-
expect(homeDir.length).toBeGreaterThan(5);
|
|
53
|
-
rmSync(homeDir, { recursive: true, force: true });
|
|
54
|
-
const environment = Environment.default;
|
|
55
|
-
environment.vars.set('log.level', MatterLogLevel.DEBUG);
|
|
56
|
-
environment.vars.set('log.format', MatterLogFormat.ANSI);
|
|
57
|
-
environment.vars.set('path.root', homeDir);
|
|
58
|
-
environment.vars.set('runtime.signals', false);
|
|
59
|
-
environment.vars.set('runtime.exitcode', false);
|
|
60
|
-
return environment;
|
|
61
|
-
}
|
|
62
117
|
export async function startServerNode(name, port) {
|
|
63
118
|
const server = await ServerNode.create({
|
|
64
119
|
id: name + 'ServerNode',
|
|
@@ -110,6 +165,7 @@ export async function startServerNode(name, port) {
|
|
|
110
165
|
expect(aggregator.lifecycle.isPartsReady).toBeTruthy();
|
|
111
166
|
expect(aggregator.lifecycle.hasId).toBeTruthy();
|
|
112
167
|
expect(aggregator.lifecycle.hasNumber).toBeTruthy();
|
|
168
|
+
await flushAsync();
|
|
113
169
|
return [server, aggregator];
|
|
114
170
|
}
|
|
115
171
|
export async function stopServerNode(server) {
|
|
@@ -124,7 +180,7 @@ export async function stopServerNode(server) {
|
|
|
124
180
|
await server.env.get(MdnsService)[Symbol.asyncDispose]();
|
|
125
181
|
await flushAsync();
|
|
126
182
|
}
|
|
127
|
-
export async function addDevice(owner, device) {
|
|
183
|
+
export async function addDevice(owner, device, pause = 10) {
|
|
128
184
|
expect(owner).toBeDefined();
|
|
129
185
|
expect(device).toBeDefined();
|
|
130
186
|
expect(owner.lifecycle.isReady).toBeTruthy();
|
|
@@ -146,9 +202,10 @@ export async function addDevice(owner, device) {
|
|
|
146
202
|
expect(device.lifecycle.hasId).toBeTruthy();
|
|
147
203
|
expect(device.lifecycle.hasNumber).toBeTruthy();
|
|
148
204
|
expect(device.construction.status).toBe(Lifecycle.Status.Active);
|
|
205
|
+
await flushAsync(1, 1, pause);
|
|
149
206
|
return true;
|
|
150
207
|
}
|
|
151
|
-
export async function deleteDevice(owner, device) {
|
|
208
|
+
export async function deleteDevice(owner, device, pause = 10) {
|
|
152
209
|
expect(owner).toBeDefined();
|
|
153
210
|
expect(device).toBeDefined();
|
|
154
211
|
expect(owner.lifecycle.isReady).toBeTruthy();
|
|
@@ -170,5 +227,6 @@ export async function deleteDevice(owner, device) {
|
|
|
170
227
|
expect(device.lifecycle.hasId).toBeTruthy();
|
|
171
228
|
expect(device.lifecycle.hasNumber).toBeTruthy();
|
|
172
229
|
expect(device.construction.status).toBe(Lifecycle.Status.Destroyed);
|
|
230
|
+
await flushAsync(1, 1, pause);
|
|
173
231
|
return true;
|
|
174
232
|
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "matterbridge",
|
|
3
|
-
"version": "3.2.7-dev-
|
|
3
|
+
"version": "3.2.7-dev-20250909-10831d3",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "matterbridge",
|
|
9
|
-
"version": "3.2.7-dev-
|
|
9
|
+
"version": "3.2.7-dev-20250909-10831d3",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@matter/main": "0.15.3",
|
package/package.json
CHANGED