---
title: "Linux App Installation Test Example"
sidebarTitle: "Linux Installer"
description: "Example test demonstrating how to download and install .deb packages and shell scripts on Linux."
icon: "download"
mode: "wide"
---

## Demo Test Run

Watch this test execute in a real sandbox environment:

{/* installer.test.mjs output */}
<iframe 
  src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d032c2e6e94933886769/replay" 
  width="100%" 
  height="390" 
  style={{ border: "1px solid #333", borderRadius: "8px" }}
  allow="fullscreen"
/>

## Source Code

```javascript title="installer.test.mjs" {16-18}
/**
 * TestDriver SDK - Installer Test (Vitest)
 * Tests the provision.installer() method for downloading and installing apps
 */

import { describe, expect, it } from "vitest";
import { TestDriver } from "testdriverai/vitest/hooks";

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

describe("Provision Installer", () => {
  it.skipIf(!isLinux)(
    "should download and install a .deb package on Linux",
    async (context) => {
      const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP});
      
      // Install bat (a cat clone with syntax highlighting) using provision.installer
      const filePath = await testdriver.provision.installer({
        url: 'https://github.com/sharkdp/bat/releases/download/v0.24.0/bat_0.24.0_amd64.deb',
      });

      // Verify the file was downloaded
      expect(filePath).toContain('bat');

      // Verify bat was installed by running it
      await testdriver.exec('sh', 'bat --version', 10000);
    },
  );

  it.skipIf(!isLinux)(
    "should download a shell script and verify it exists",
    async (context) => {
      const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP});
      
      // Download a shell script (nvm installer)
      const filePath = await testdriver.provision.installer({
        url: 'https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh',
        launch: false, // Don't auto-run the script
      });

      // Verify the file was downloaded
      expect(filePath).toContain('install.sh');

      // Verify the file is executable
      const result = await testdriver.exec('sh', `ls -la "${filePath}"`, 10000);
      expect(result).toBeTruthy();
    },
  );
});
```

## Running This Example

```bash
# 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/installer.test.mjs
```

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