← ClaudeAtlas

testdriverreusable-codelisted

Build maintainable test suites with reusable code patterns
testdriverai/testdriverai · ★ 243 · Testing & QA · score 73
Install: claude install-skill testdriverai/testdriverai
<!-- Generated from reusable-code.mdx. DO NOT EDIT. --> When your test suite becomes larger, put the common patterns into reusable code. This keeps the tests short, easy to read, and easy to keep. ## Helper Functions The most simple method is to put the common actions into helper functions. Make a `helpers/` directory for the shared utilities: ```javascript test/helpers/auth.js export async function login(testdriver, { email, password }) { const emailInput = await testdriver.find('email input'); await emailInput.click(); await testdriver.type(email); const passwordInput = await testdriver.find('password input'); await passwordInput.click(); await testdriver.type(password); const loginButton = await testdriver.find('login button'); await loginButton.click(); const result = await testdriver.assert('user is logged in'); return result; } export async function logout(testdriver) { const userMenu = await testdriver.find('user menu'); await userMenu.click(); const logoutButton = await testdriver.find('logout button'); await logoutButton.click(); } ``` <Warning> **Do not put dynamic values in element descriptions.** An element selector must describe the *type* of the element. It must not describe specific content that can change. **❌ Bad:** `await testdriver.find('profile name TestDriver in the top right')` **✅ Good:** `await testdriver.find('user profile name in the top right')` Hardcoded values like usernames, product names, or pric