> ## Documentation Index
> Fetch the complete documentation index at: https://docs.testdriver.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Launching VS Code Test Example

> Example test demonstrating how to launch VS Code and install extensions on Linux.

## Demo Test Run

Watch this test execute in a real sandbox environment:

<iframe src="https://console-test.testdriver.ai/replay/6a052242ef91e2fc9cb2047e?share=t1MuUD91c9Fo2POIPilaw&embed=true" width="100%" height="390" style={{ border: "1px solid #333", borderRadius: "8px" }} allow="fullscreen" />

## Source Code

```javascript title="launch-vscode-linux.test.mjs" {13,27-29} theme={null}
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

```bash theme={null}
# 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
```

<Note>
  Make sure you have `TD_API_KEY` set in your environment. Get one at [testdriver.ai](https://testdriver.ai).
</Note>
