跳到正文
cccskills
免费在 GitHub 公开

testdriver:caching

1.7x faster test execution with intelligent caching and optimization

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(1)

  • SKILL.md3.8 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

<!-- Generated from caching.mdx. DO NOT EDIT. -->

TestDriver is engineered for performance with intelligent caching that delivers up to 1.7x faster test execution by skipping redundant AI vision analysis.

// First run: builds cache
await testdriver.find('submit button');

// Second run: exact match
await testdriver.find('submit button');

Automatic Caching

Caching is enabled automatically with zero configuration. The cache key is computed from:

  • File hash: SHA-256 hash of the test file contents
  • Selector prompt: The exact text description passed to find()
  • Screenshot context: Perceptual hash of the current screen state
  • Platform: Operating system and browser version

When you modify your test file, the hash changes automatically, invalidating stale cache entries and ensuring fresh AI analysis with your updated test logic.

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

test('auto-cached test', async (context) => {
  const { testdriver } = await chrome(context, {
    url: 'https://example.com'
  });

  // First call: AI analyzes screen, saves to cache
  await testdriver.find('More information link'); // 2.1s

  // Second call: cache hit, instant response
  await testdriver.find('More information link'); // 12ms ⚡
});

Managing the Cache

You can clear the cache within the TestDriver console. There, you'll also find previews of cached elements, the input prompts, as well as analytics on cache hit rates.

<Card href="https://console.testdriver.ai/cache" title="TestDriver Cache" icon="database"> Manage and clear your test cache from the TestDriver console. </Card>

Debugging Cache Hits and Misses

You can track cache performance in your tests:

test('monitor cache performance', async (context) => {
  const { testdriver } = await chrome(context, { url });

  const element = await testdriver.find('submit button');

  if (element.cacheHit) {
    console.log('✅ Cache hit - instant response');
    console.log('Strategy:', element.cacheStrategy); // 'exact', 'pixeldiff', or 'template'
    console.log('Similarity:', `${(element.similarity * 100).toFixed(1)}%`);
    console.log('Cache age:', element.cacheCreatedAt);
  } else {
    console.log('⏱️  Cache miss - AI analysis performed');
    console.log('New cache entry created');
  }
});

Configuring the Cache

You can configure cache behavior globally when initializing TestDriver:

import { TestDriver } from 'testdriverai';

const testdriver = new TestDriver({
  apiKey: process.env.TD_API_KEY,
  cacheKey: 'my-test-suite', // cache-key for this instance
  cacheDefaults: {
    threshold: 0.05,      // 95% similarity
  }
});

It's also possible to override cache settings per find() call:

// Default: 95% similarity required
await testdriver.find('submit button');

// Explicit strict threshold
await testdriver.find('submit button', {
  cacheThreshold: 0.01 // 99% similarity
});

Caching with Variables

Custom cache keys prevent cache pollution when using variables in prompts, dramatically improving cache hit rates.

// ❌ Without cache key - creates new cache for each variable value
const email = 'user@example.com';
await testdriver.find(`input for ${email}`); // Cache miss every time

// ✅ With cache key - reuses cache regardless of variable
const email = 'user@example.com';
await testdriver.find(`input for ${email}`, {
  cacheKey: 'email-input'
});

// Also useful for dynamic IDs, names, or other changing data
const orderId = generateOrderId();
await testdriver.find(`order ${orderId} status`, {
  cacheKey: 'order-status'  // Same cache for all orders
});

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

How the TestDriver agent behaves on GitHub issues, pull requests, and @mentions

中文简介正在准备中。当前显示原文说明。

testdriverai/testdriverai4062026年9月21日 更新

Execute natural language tasks using AI

中文简介正在准备中。当前显示原文说明。

testdriverai/testdriverai4062026年9月21日 更新

Make AI-powered assertions about screen state

中文简介正在准备中。当前显示原文说明。

testdriverai/testdriverai4062026年9月21日 更新

Deploy TestDriver on your AWS infrastructure using CloudFormation

中文简介正在准备中。当前显示原文说明。

testdriverai/testdriverai4062026年9月21日 更新

Speed up tests with screenshot-based caching

中文简介正在准备中。当前显示原文说明。

testdriverai/testdriverai4062026年9月21日 更新

How TestDriver learns your app and caches what it discovers for instant, deterministic replays

中文简介正在准备中。当前显示原文说明。

testdriverai/testdriverai4062026年9月21日 更新

查看 testdriverai 的全部技能

报告此技能的问题