Skip to content
Back to skills

Test Rename Drift

ASecurity

When renaming a function, test files have references that survive find-and-replace:

  • 4 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 3, 2026
ai-agentsjavascriptjavabashnodetestingrefactoring

Security analysis

A100/100

Scanned September 3, 2026

npx -y skills add fabioc-aloha/Alex_Skill_Mall --skill test-rename-drift --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Test Rename Drift?

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

Security grade badge for Test Rename Drift
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/fabioc-aloha-test-rename-drift/badge)](https://www.skillsdirectory.com/skills/fabioc-aloha-test-rename-drift)

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: test-rename-drift
description: "When renaming a function, test files have references that survive find-and-replace:"
lastReviewed: 2026-04-30
---

# Test Rename Drift

## The Problem

When renaming a function, test files have references that survive find-and-replace:

```javascript
// Old function: calculateTotal()
// New function: computeTotal()

// Find-and-replace catches: calculateTotal(
// But misses:
describe('calculateTotal', () => {  // Describe block
  // tests for calculateTotal    // Comment
  it('calculateTotal returns sum', () => { // It block text
```

## The Solution

Grep for BOTH the old AND new name after renaming.

```bash
# After renaming calculateTotal → computeTotal

# Find remaining old references
grep -rn "calculateTotal" . --include="*.test.*" --include="*.spec.*"

# Verify new references exist
grep -rn "computeTotal" . --include="*.test.*" --include="*.spec.*"
```

## Checklist

| Location | Find Pattern | Replace? |
|----------|--------------|----------|
| Function calls | `oldName(` | ✅ Auto |
| Import statements | `import { oldName }` | ✅ Auto |
| Describe blocks | `describe('oldName'` | ❌ Manual |
| It block text | `it('oldName should'` | ❌ Manual |
| Comments | `// oldName does X` | ❌ Manual |
| Variable names | `const oldNameResult` | Depends |
| Mock names | `jest.mock('oldName')` | ❌ Manual |
| Snapshot files | Contains "oldName" | ❌ Manual |

## Automated Check

```javascript
// scripts/check-rename-drift.cjs
const oldName = process.argv[2];
const newName = process.argv[3];

const { execSync } = require('child_process');

const oldRefs = execSync(
  `grep -rn "${oldName}" . --include="*.test.*" --include="*.spec.*" || true`,
  { encoding: 'utf8' }
);

if (oldRefs.trim()) {
  console.error(`Found ${oldRefs.split('\n').length - 1} remaining references to "${oldName}":`);
  console.error(oldRefs);
  process.exit(1);
}

console.log(`No remaining references to "${oldName}" in test files.`);
```

## Verification

```bash
# Run after any rename
node scripts/check-rename-drift.cjs oldFunctionName newFunctionName

# Should report: "No remaining references"
```

## When to Apply

- After any function/class/method rename
- Before committing renamed code
- During code review of renames

## Tags

`quality` `testing` `refactoring` `rename`

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.