Skip to main content

Demo Test Run

Watch this test execute in a real sandbox environment:

Source Code

launch-vscode-linux.test.mjs
import { describe, expect, it } from "vitest";
import { TestDriver } from "testdriverai/vitest/hooks";

const isLinux = (process.env.TD_OS || "linux") === "linux";

describe("Launch VS Code on Linux", () => {
  it.skipIf(!isLinux)(
    "should launch VS Code on Debian/Ubuntu",
    async (context) => {
      const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP});
      
      // provision.vscode() automatically calls ready() and starts dashcam
      await testdriver.provision.vscode();

      // Wait for VS Code to launch (polls every 5s until found or timeout)
      const vsCodeWindow = await testdriver.find(
        "Visual Studio Code window",
        { timeout: 60000 }
      );
      expect(vsCodeWindow.found()).toBeTruthy();
    },
  );

  // it.skipIf(!isLinux)(
  //   "should install and use a VS Code extension",
  //   async (context) => {
  //     const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP});
      
  //     // Launch VS Code with the Prettier extension installed
  //     await testdriver.provision.vscode({
  //       extensions: ["esbenp.prettier-vscode"],
  //     });

  //     const vsCodeWindow = await testdriver.find(
  //       "Visual Studio Code window",
  //       { timeout: 60000 }
  //     );

  //     expect(vsCodeWindow.found()).toBeTruthy();

  //     // Open the extensions panel to verify Prettier is installed
  //     await testdriver.pressKeys(["ctrl", "shift", "x"]);
      
  //     // Wait for extensions panel to open
  //     await new Promise((resolve) => setTimeout(resolve, 2000));

  //     // Assert that Prettier extension is visible in the installed extensions
  //     const prettierVisible = await testdriver.assert(
  //       "Prettier extension is visible in the extensions panel or sidebar",
  //     );
  //     expect(prettierVisible).toBeTruthy();
  //   },
  // );
});

Running This Example

# Clone the TestDriver repository
git clone https://github.com/testdriverai/testdriverai

# Install dependencies
cd testdriverai
npm install

# Run this specific example
npx vitest run examples/launch-vscode-linux.test.mjs
Make sure you have TD_API_KEY set in your environment. Get one at testdriver.ai.