Skip to content
Back to skills

Testdriver Variables

ASecurity

Use dynamic data and secure secrets in your tests

  • 243 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 6, 2026
ai-agentsjavascriptjavabashtesting

Works with

  • cli

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned September 22, 2026

npx -y skills add testdriverai/testdriverai --skill testdriver-variables --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Testdriver Variables?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Testdriver Variables
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/testdriverai-testdriver-variables/badge)](https://www.skillsdirectory.com/skills/testdriverai-testdriver-variables)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: testdriver:variables
description: Use dynamic data and secure secrets in your tests
---
<!-- Generated from variables.mdx. DO NOT EDIT. -->

Make your tests larger with dynamic data and secure secrets. Select the correct method for your test needs.

## Environment Variables

Use environment variables for **configuration that changes between environments** (dev, staging, production). Also use them for **secrets that you must not commit to the code**. Use this method when you must run the same tests against different servers or with different credentials.

```javascript
import { test } from 'vitest';
import { chrome } from 'testdriverai/presets';

test('multi-environment testing', async (context) => {
  const env = process.env.TEST_ENV || 'staging';
  const urls = {
    dev: 'https://dev.myapp.com',
    staging: 'https://staging.myapp.com',
    production: 'https://myapp.com'
  };

  const { testdriver } = await chrome(context, { 
    url: urls[env] 
  });

  await testdriver.assert('app is running');
});
```

```bash
# Run against different environments
TEST_ENV=dev vitest run
TEST_ENV=staging vitest run
TEST_ENV=production vitest run
```

## Test Fixtures

Test fixtures work best when you have **structured, reusable test data** that needs to be shared across multiple tests. Use fixtures when testing different user roles, product catalogs, or any scenario where you want to parameterize tests with a known set of data.

```javascript test/fixtures/users.js
export const testUsers = [
  { email: 'admin@test.com', role: 'admin' },
  { email: 'user@test.com', role: 'user' },
  { email: 'guest@test.com', role: 'guest' }
];

export const products = [
  { name: 'Laptop', price: 999 },
  { name: 'Mouse', price: 29 },
  { name: 'Keyboard', price: 89 }
];
```

```javascript test/permissions.test.js
import { test } from 'vitest';
import { chrome } from 'testdriverai/presets';
import { testUsers } from './fixtures/users.js';

test.each(testUsers)('$role can access dashboard', async ({ email, role }, context) => {
  const { testdriver } = await chrome(context, { url });
  
  await testdriver.find('email input').type(email);
  await testdriver.find('password input').type('password123');
  await testdriver.find('login button').click();
  
  if (role === 'admin') {
    await testdriver.assert('admin panel is visible');
  } else {
    await testdriver.assert('user dashboard is visible');
  }
});
```

## Dynamic Data Generation

Dynamic data generation is perfect for **creating unique test data on each run**, avoiding conflicts with existing records, and **testing edge cases with realistic data**. Use libraries like Faker when you need fresh emails, names, or other data that won't collide with previous test runs.

```javascript
import { test } from 'vitest';
import { chrome } from 'testdriverai/presets';
import { faker } from '@faker-js/faker';

test('user registration with dynamic data', async (context) => {
  const { testdriver } = await chrome(context, { url });

  // Generate unique test data for each run
  const userData = {
    firstName: faker.person.firstName(),
    lastName: faker.person.lastName(),
    email: faker.internet.email(),
    password: faker.internet.password({ length: 12 })
  };

  await testdriver.find('first name input').type(userData.firstName);
  await testdriver.find('last name input').type(userData.lastName);
  await testdriver.find('email input').type(userData.email);
  await testdriver.find('password input').type(userData.password);
  await testdriver.find('register button').click();

  await testdriver.assert('registration successful');
  console.log('Registered user:', userData.email);
});
```

```bash
npm install --save-dev @faker-js/faker
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.