Skip to content

Commit 04a8889

Browse files
committed
attempt to fix macOS test
1 parent 8593515 commit 04a8889

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/__tests__/server.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ async function waitForPlottingComplete(server: Server, timeout = 10000): Promise
4747
}
4848
}
4949

50+
async function waitForCommandsLogged(timeout = 5000): Promise<void> {
51+
const startTime = Date.now();
52+
while (Date.now() - startTime < timeout) {
53+
if (mockSerialPortInstance.commands.length > 0) break;
54+
await new Promise(resolve => setTimeout(resolve, 10));
55+
}
56+
}
57+
5058
describe('Plot Endpoint Test Suite', () => {
5159
let server: Server;
5260

@@ -75,6 +83,9 @@ describe('Plot Endpoint Test Suite', () => {
7583
.send(SIMPLE_PLAN)
7684
.expect(200);
7785

86+
// Wait for the plotting to actually start and commands to be logged
87+
await waitForCommandsLogged();
88+
7889
// Check the commands that were sent to the mock serial port
7990
expect(mockSerialPortInstance.commands.length).toBeGreaterThan(0);
8091
expect(mockSerialPortInstance.commands).toContain('EM,1,1');

0 commit comments

Comments
 (0)