What You’ll Learn
- Generate unit tests covering edge cases and expected behavior
- Work with all major testing frameworks (Jest, Pytest, JUnit, etc.)
- Create integration tests verifying multi-component workflows
- Improve test coverage by identifying and testing uncovered code paths
- Debug issues using error message analysis and execution tracing
- Diagnose bugs from stack traces, error logs, and unexpected behavior
Prerequisites
Before testing and debugging with Verdent:- Visual Studio Code with Verdent extension installed
- A codebase or project workspace open in VS Code
- Active Verdent subscription with available credits
- Testing framework configured in your project (optional for test generation)
Writing Unit Tests
Verdent generates unit tests that match your project’s testing framework and style. It analyzes existing tests to understand your patterns, then generates tests with proper setup, assertions, and mocking. Example:- Examine the
calculateDiscountfunction implementation - Identify input parameters and return values
- Analyze existing tests to match your conventions (test structure, assertion style, naming patterns)
- Generate tests covering:
- Happy path: Valid inputs with expected outputs
- Edge cases: Boundary values, zero, negative numbers, maximum values
- Invalid inputs: null, undefined, wrong types
- Expected behavior: Business logic validation
- Test suite organization: Describe blocks, test classes, or module structure
- Setup and teardown: Before/after hooks matching your existing tests
- Assertions: Using your project’s assertion library (expect, assert, should, etc.)
- Mocking: Matching your mocking patterns (jest.mock, sinon, unittest.mock)
- Naming conventions: Test names following your established style
- Generate: Create initial test suite
- Run: Execute tests to verify they work
- Repair: Fix failing tests or improve coverage
- Iterate: Repeat until tests pass and coverage is sufficient
Supported Test Frameworks
Verdent supports all major testing frameworks across different programming languages and technology stacks without requiring additional configuration.- JavaScript/TypeScript
- Python
- Java & JVM
- Other Languages
Unit Testing Frameworks:Framework-Specific Testing:
- React Testing Library - User-centric React component testing
- Vue Test Utils - Official Vue.js testing library
- Cypress - End-to-end and component testing
- Playwright - Cross-browser end-to-end testing
- Puppeteer - Headless Chrome testing
Generating Integration Tests
Verdent generates integration tests that verify how multiple components, services, or modules work together. It creates tests simulating real workflows including API interactions, database operations, authentication flows, and multi-step user journeys. Example:- Form Submission: User submits registration form with valid data
- Validation: Backend validates email format, password strength, data completeness
- Database Insertion: User record is created in the database
- Email Sending: Confirmation email is sent (mocked or actual)
- Successful Login: New user can immediately log in with credentials
- Test Setup: Database seeding, service initialization, test data creation
- Workflow Simulation: Multi-step operations in sequence
- State Verification: Checking database state, API responses, side effects
- Mocking External Services: Email services, payment APIs, third-party integrations
- Test Teardown: Cleanup of test data, database rollback, service shutdown
- Adding items to cart
- Applying discount codes
- Calculating totals with tax and shipping
- Processing payment (with mocked payment gateway)
- Creating order record in database
- Sending confirmation email
- Updating inventory
- Each test starts with a clean database state
- External service calls are mocked to prevent side effects
- Tests can run in any order without dependencies
- Cleanup happens even if tests fail
Integration tests verify that components work together correctly. They’re more complex than unit tests but provide higher confidence that real-world workflows function as expected.
Improving Test Coverage
Verdent analyzes your codebase to identify untested functions, branches, and edge cases, then generates tests to improve coverage. It examines your existing test suite and identifies gaps where code paths aren’t exercised. Example:- Analyze Existing Tests: Examine what’s currently tested
- Identify Coverage Gaps: Find specific functions, conditional branches, error handling paths, and edge cases lacking tests
- Generate Missing Tests: Create tests targeting uncovered code
- Verify Coverage Improvement: Run tests to confirm coverage increases
- Untested Functions: Functions with no test coverage at all
- Conditional Branches: If/else statements where one branch isn’t tested
- Error Handling Paths: Try/catch blocks or error callbacks without failure tests
- Edge Cases: Boundary values, null/undefined handling, type coercion
- Integration Points: API calls, database operations, external service interactions
getUserByIdhas tests for valid IDs but not invalid IDsupdateUsermissing tests for validation failuresdeleteUsermissing tests for authorization checks- Error handling paths in
createUserare untested
- Line Coverage: Percentage of code lines executed by tests
- Branch Coverage: Percentage of conditional branches tested
- Function Coverage: Percentage of functions with at least one test
- Statement Coverage: Percentage of statements executed
Debugging with Verdent
Verdent helps debug by analyzing error messages, tracing execution flow, identifying root causes, and suggesting fixes. Paste error logs, describe unexpected behavior, or ask Verdent to investigate specific issues.- Unexpected Behavior
- Performance Issues
- Execution Flow
Describe what’s wrong and what you expected:Verdent will:Verdent will:
- Read the function implementation
- Trace the execution flow
- Identify where the code path goes wrong (missing return statement, incorrect conditional, async/await issue)
- Propose a fix with explanation
- Suggest test cases to prevent regression
- Examine the login form submission logic
- Trace authentication flow
- Identify the bug (redirect happens before async validation completes)
- Propose a fix (await validation before redirecting)
Diagnosing from Error Messages and Logs
Paste error messages, stack traces, or log files directly into the chat. Verdent analyzes the error, identifies the source file and line number, explains the cause, and suggests a fix.- Stack Traces
- Log Analysis
- Multi-Step Debugging
Paste error messages and stack traces:Paste this into Verdent:Verdent will:
- Identify the error type (TypeError from null/undefined access)
- Locate the exact line (
UserProfile.jsx:45) - Read the code at that location
- Explain why it’s happening (user object is undefined before data loads)
- Propose fixes:
- Add null check:
if (!user) return <Loading /> - Use optional chaining:
user?.name - Ensure data loads before rendering component
- Add null check:
Best Practices
Generate tests early
Generate tests early
Write tests as you develop features, not after completion. Verdent can generate tests immediately after creating new functions or components.
Use existing tests as style guides
Use existing tests as style guides
Verdent matches your project’s testing patterns. Maintain consistent test structure so Verdent generates tests that align with your conventions.
Request tests for edge cases explicitly
Request tests for edge cases explicitly
Ask Verdent to test boundary conditions, error scenarios, and unusual inputs: “Write tests including edge cases for invalid inputs and boundary values.”
Paste error messages directly
Paste error messages directly
Don’t paraphrase errors. Paste the complete stack trace for accurate diagnosis and faster resolution.
Describe expected vs actual behavior
Describe expected vs actual behavior
When debugging, clearly state what you expected to happen and what actually happened. This context helps Verdent identify the root cause.
Use multipass testing for complex features
Use multipass testing for complex features
For critical features, request comprehensive test generation with multipass cycles: “Generate comprehensive tests for the payment module and verify they all pass.”
Test after refactoring
Test after refactoring
After refactoring code, request tests to verify functionality is preserved: “Generate tests to verify the refactored authentication module works correctly.”
Combine debugging with test generation
Combine debugging with test generation
After fixing a bug, request a test to prevent regression: “Write a test that ensures this bug doesn’t happen again.”