Skip to content

Commit

Permalink
Fix js/lite/src/custom-element/index.test.ts that has been failing fr…
Browse files Browse the repository at this point in the history
…equently (#10287)

* Fix js/lite/src/custom-element/index.test.ts that has been failing frequently

* Delete the vite-environment specification
  • Loading branch information
whitphx authored Jan 5, 2025
1 parent 5ce2832 commit 2c099f8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions js/lite/src/custom-element/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import { bootstrap_custom_element } from "./index";

const delay = (ms?: number) =>
new Promise((resolve) => setTimeout(resolve, ms));
const awaitAnimationFrame = () =>
new Promise((resolve) => window.requestAnimationFrame(resolve));

describe("bootstrap_custom_element", () => {
const create = vi.fn();
Expand All @@ -20,7 +20,7 @@ describe("bootstrap_custom_element", () => {
import gradio as gr
</gradio-lite>
`;
await delay(); // Wait for the requestAnimationFrame to run
await awaitAnimationFrame(); // Wait for `create` to be called in the `requestAnimationFrame` callback

expect(create).toHaveBeenCalledWith(
expect.objectContaining({
Expand All @@ -44,7 +44,7 @@ scipy
</gradio-requirements>
</gradio-lite>
`;
await delay(); // Wait for the requestAnimationFrame to run
await awaitAnimationFrame(); // Wait for `create` to be called in the `requestAnimationFrame` callback

expect(create).toHaveBeenCalledWith(
expect.objectContaining({
Expand Down Expand Up @@ -75,7 +75,7 @@ scipy
</gradio-requirements>
</gradio-lite>
`;
await delay(); // Wait for the requestAnimationFrame to run
await awaitAnimationFrame(); // Wait for `create` to be called in the `requestAnimationFrame` callback

expect(create).toHaveBeenCalledWith(
expect.objectContaining({
Expand All @@ -100,7 +100,7 @@ scipy
import gradio as gr
</gradio-lite>
`;
await delay(); // Wait for the requestAnimationFrame to run
await awaitAnimationFrame(); // Wait for `create` to be called in the `requestAnimationFrame` callback

expect(create).toHaveBeenCalledWith(
expect.objectContaining({
Expand All @@ -119,7 +119,7 @@ scipy
</gradio-code>
</gradio-lite>
`;
await delay(); // Wait for the requestAnimationFrame to run
await awaitAnimationFrame(); // Wait for `create` to be called in the `requestAnimationFrame` callback

expect(create).toHaveBeenCalledWith(
expect.objectContaining({
Expand Down Expand Up @@ -149,7 +149,7 @@ scipy
</gradio-file>
</gradio-lite>
`;
await delay(); // Wait for the requestAnimationFrame to run
await awaitAnimationFrame(); // Wait for `create` to be called in the `requestAnimationFrame` callback

expect(create).toHaveBeenCalledWith(
expect.objectContaining({
Expand Down

0 comments on commit 2c099f8

Please sign in to comment.