Skip to content

Commit c7ea7ea

Browse files
Fix flaky Selenium test (#929)
1 parent 3574498 commit c7ea7ea

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

packages/modules/selenium/src/selenium-container.test.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
11
import path from "path";
22
import { Browser, Builder } from "selenium-webdriver";
3-
import { GenericContainer, StartedTestContainer } from "testcontainers";
3+
import { GenericContainer } from "testcontainers";
44
import tmp from "tmp";
55
import { SeleniumContainer, SELENIUM_VIDEO_IMAGE } from "./selenium-container";
66

77
describe("SeleniumContainer", { timeout: 180_000 }, () => {
8-
let ffmpegContainer: StartedTestContainer;
9-
10-
beforeAll(async () => {
11-
ffmpegContainer = await new GenericContainer(SELENIUM_VIDEO_IMAGE).withCommand(["sleep", "infinity"]).start();
12-
});
13-
14-
afterAll(async () => {
15-
await ffmpegContainer.stop();
16-
});
17-
188
const browsers = [
199
["CHROME", process.arch === "arm64" ? `seleniarm/standalone-chromium:112.0` : `selenium/standalone-chrome:112.0`],
2010
["FIREFOX", process.arch === "arm64" ? `seleniarm/standalone-firefox:112.0` : `selenium/standalone-firefox:112.0`],
@@ -43,9 +33,13 @@ describe("SeleniumContainer", { timeout: 180_000 }, () => {
4333
const videoFileName = path.basename(videoFilePath);
4434
await stoppedContainer.saveRecording(videoFilePath);
4535

36+
const ffmpegContainer = await new GenericContainer(SELENIUM_VIDEO_IMAGE)
37+
.withCommand(["sleep", "infinity"])
38+
.start();
4639
await ffmpegContainer.copyFilesToContainer([{ source: videoFilePath, target: `/tmp/${videoFileName}` }]);
4740
const { exitCode } = await ffmpegContainer.exec(["ffprobe", `/tmp/${videoFileName}`]);
4841
expect(exitCode).toBe(0);
42+
await ffmpegContainer.stop();
4943
});
5044
});
5145
});

packages/testcontainers/src/container-runtime/utils/image-exists.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Dockerode from "dockerode";
2-
import { afterEach } from "vitest";
32
import { ImageName } from "../image-name";
43

54
const mockImageInspect = vi.fn();

0 commit comments

Comments
 (0)