Skip to content

Commit 69f4905

Browse files
committed
fix(tests): Add small delay before signaling for worker to actually wait
1 parent 59e01ae commit 69f4905

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

tests/ut/sync/AutoResetEvent.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect } from 'chai';
33
import { sinon } from '../../setup.js';
44
import { AutoResetEvent } from '../../../src/sync/AutoResetEvent.js';
55
import { autoResetEventIdentityData } from '../../../src/sync/identifiers.js';
6-
import { testAutoResetEventWaitInWorker } from '../helpers/helpers.js';
6+
import { delay, testAutoResetEventWaitInWorker } from '../helpers/helpers.js';
77
import { ManualResetEvent } from '../../../src/sync/ManualResetEvent.js';
88

99
describe('AutoResetEvent', () => {
@@ -87,6 +87,7 @@ describe('AutoResetEvent', () => {
8787
it('Should wait and succeed when signal becomes available.', async () => {
8888
const waitComplete = (await testAutoResetEventWaitInWorker(eventObj.token, 1000)).wait;
8989

90+
await delay(50); // Ensure the worker is waiting
9091
eventObj.signal();
9192

9293
const result = await waitComplete;

tests/ut/sync/ManualResetEvent.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { describe, it, beforeEach } from 'mocha';
22
import { expect } from 'chai';
33
import { sinon } from '../../setup.js';
44
import { ManualResetEvent } from '../../../src/sync/ManualResetEvent.js';
5-
import { testManualResetEventWaitInWorker, tokenTypeTest } from '../helpers/helpers.js';
5+
import { delay, testManualResetEventWaitInWorker, tokenTypeTest } from '../helpers/helpers.js';
66
import { manualResetEventIdentityData } from '../../../src/sync/identifiers.js';
77
import { AutoResetEvent } from '../../../src/sync/AutoResetEvent.js';
88

@@ -80,6 +80,7 @@ describe('ManualResetEvent', () => {
8080
it('Should wait and succeed when signal becomes available.', async () => {
8181
const waitComplete = (await testManualResetEventWaitInWorker(eventObj.token, 1000)).wait;
8282

83+
await delay(50); // Ensure the worker is waiting
8384
eventObj.signal();
8485

8586
const result = await waitComplete;

0 commit comments

Comments
 (0)