Skip to content

Commit

Permalink
fix: flaky tests (#7358)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone authored Nov 4, 2024
1 parent 8a826bd commit b18d233
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/config/src/_version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// This file is auto-generated by the codegen maintenance script
export const PACKAGE_VERSION = "14.0.0-beta.1";
export const PACKAGE_VERSION = "14.0.0-beta.3";
2 changes: 1 addition & 1 deletion packages/zwave-js/src/lib/_version.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// This file is auto-generated by the codegen maintenance script
export const PACKAGE_VERSION = "14.0.0-beta.1";
export const PACKAGE_VERSION = "14.0.0-beta.3";
export const PACKAGE_NAME = "zwave-js";
12 changes: 9 additions & 3 deletions packages/zwave-js/src/lib/driver/Task.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,18 +511,21 @@ test("Waiting tasks are deprioritized over tasks with a higher priority", async
scheduler.start();

const yieldedPromise = createDeferredPromise<void>();
const t1WasStarted = createDeferredPromise<void>();

const task1 = scheduler.queueTask({
priority: TaskPriority.Normal,
task: async function*() {
t1WasStarted.resolve();
order.push("1a");
yield () => yieldedPromise;
order.push("1b");
return;
},
});

await wait(1);
// The test expects that task 1 has started executing before task 2 is queued
await t1WasStarted;

const task2 = scheduler.queueTask({
priority: TaskPriority.High,
Expand Down Expand Up @@ -1208,9 +1211,12 @@ test("The task rejection uses the given error, if any", async (t) => {
const order: string[] = [];
scheduler.start();

const t1WasStarted = createDeferredPromise<void>();

const task1 = scheduler.queueTask({
priority: TaskPriority.Normal,
task: async function*() {
t1WasStarted.resolve();
order.push("1a");
yield () => wait(10);
order.push("1b");
Expand All @@ -1222,8 +1228,8 @@ test("The task rejection uses the given error, if any", async (t) => {
},
});

await wait(1);
// The task should have run to the first yield
// task 1 has run to the first yield
await t1WasStarted;
t.expect(order).toStrictEqual(["1a"]);

await scheduler.removeTasks(
Expand Down

0 comments on commit b18d233

Please sign in to comment.