AI Prompts for Identify Causes of Test Failures

20 of the best prompts for identify causes of test failures, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.

AI Prompts for Identify Causes of Test Failures

20 of the best prompts for identify causes of test failures, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.

Scroll to explore

Test failures can arise unexpectedly after changes, leading to confusion and wasted debugging time. If these failures are not addressed, they can hinder development progress and lead to deployment issues. By following this guide, developers can systematically diagnose and resolve the underlying causes of test failures in their Bolt applications. Built across 4 distinct stages covering Diagnose the Wall, Isolate and Fix, Verify the Resolution and more, this guide gives you one expert prompt per step so you never have to write from scratch or guess what the AI needs. The prompts work in ChatGPT, Claude, and Gemini and are designed to get usable output on the first try.

Diagnose the Wall

Before attempting any fix, identify the specific test that is failing and the error message it produces. This will help in pinpointing the source of the issue.

Quote the Failing Test Output

Please provide the exact output from the last test run that failed. Include the name of the test and the specific error message it produced. Additionally, summarize what the expected behavior was and how it differs from the actual outcome, so I can better understand the issue at hand.

Diagnose the Wall

Paste the Failing Test Code

Please analyze the following failing test code: [FAILING TEST CODE]. Identify the specific function or method being tested and explain any changes that may have contributed to the failure. Additionally, provide suggestions for how to fix the issues and improve the test to prevent future failures.

Diagnose the Wall

Interpret the Original Instruction

Please interpret the original instruction provided for the test. Clearly outline your understanding of the requirements, highlighting any potential areas of confusion or ambiguity. After your interpretation, suggest how this understanding could impact the approach to retrying the test. Format your response in a structured manner, with headings for "Interpretation" and "Impact on Retest.

Diagnose the Wall

Expected vs. Actual Test Behavior

Please provide a detailed comparison of the expected behavior versus the actual behavior observed in the test for [TEST NAME]. Clearly outline the expected outcome, including specific metrics or criteria, and describe the actual results produced by the test. Additionally, highlight any discrepancies between the two and suggest potential reasons for these differences, along with recommendations for further investigation or adjustments needed to align the test outcomes with expectations.

Diagnose the Wall

Identify the Violated Rule

Identify the specific rule or constraint that was violated, which led to the test failure in the context of [USE-CASE]. Please quote the exact clause from the test requirements that was not met and provide a brief explanation of how this violation impacted the overall test results. Format your response as a structured report with headings for the violated rule, the quoted clause, and the impact analysis.

Diagnose the Wall

Isolate and Fix

Focus on the specific code or configuration that needs to be corrected to resolve the test failures. This will involve targeted adjustments.

Correct the Test Function Signature

Please review the function signature located at [FILE]:[LINE]. The original signature is: [PASTE]. The modified signature is: [PASTE]. I need you to revert the signature back to the original while leaving the function body unchanged. Before applying the change, provide me with a diff of the modifications for review.

Isolate and Fix

Rewrite the Test with Constraints

Rewrite the failing test to include explicit constraints. The test should ensure that [SPECIFIC CONDITION] is met. If this condition is not satisfied, the test should fail. Please provide the updated test code in a clear and structured format, including any necessary comments to explain the constraints implemented.

Isolate and Fix

Scoped Change to Test Setup

Adjust the setup portion of the test located in [FILE]:[LINE]. Ensure that it correctly initializes the necessary context for the test to run successfully. Provide a detailed explanation of the changes made and how they improve the test's reliability. Additionally, include any relevant code snippets that demonstrate the new setup and its impact on the test outcomes.

Isolate and Fix

Enforce Test Format Consistency

Check the format of the test in [FILE] at line [LINE]. Ensure it adheres to the required structure: 'describe([TEST NAME], () => { it([TEST CASE], () => { [ASSERTIONS] }); });'. If the format is incorrect, provide the corrected version along with a brief explanation of the changes made to ensure consistency.

Isolate and Fix

Verify Dependency Imports

Review the imports in the file located at [FILE] on line [LINE]. Confirm that all dependencies required for the test are correctly imported and available. If any dependencies are missing, please list them as UNVERIFIED and provide a brief explanation of why each missing dependency is necessary for the test to function properly.

Isolate and Fix

Verify the Resolution

Confirm that the previously failing test now passes successfully. This validation is crucial to ensure the fix was effective.

Run the Fixed Test

Please execute the fixed test located in [FILE] at line [LINE]. Confirm whether the test passes without any errors and provide the complete output of the test run, including any relevant logs or messages that indicate the test's success or failure. Additionally, summarize any issues encountered during the test execution.

Verify the Resolution

Show the Diff of Changes

Display the diff of changes made to the test in [FILE] at line [LINE]. Highlight the specific modifications and confirm whether these changes effectively address the previous failure. Additionally, provide a brief explanation of how the changes resolve the issue and any potential implications for future tests.

Verify the Resolution

Replay the Original Failing Test

Replay the original failing test scenario for the use-case of [USE-CASE NAME] to verify that it now passes successfully. Please provide the detailed output of the test execution, including any relevant logs or messages, and confirm whether the expected behavior has been achieved. Additionally, summarize any changes made to ensure the test now passes.

Verify the Resolution

Check Edge Cases for Regression

Identify and run edge cases related to the fixed test for [TEST NAME]. Please confirm that these edge cases do not cause any regressions in the test outcomes. Provide a detailed report that includes the edge cases tested, the results of each test, and any observations or issues encountered during the testing process.

Verify the Resolution

Confirm Test Output State

Verify the output state of the test located in [FILE] at line [LINE]. After applying the fix, check if the output matches the expected results. Please present a comparison of the expected output versus the actual output in a clear format, highlighting any discrepancies.

Verify the Resolution

Prevent Recurrence

Implement artefacts that help prevent similar test failures from occurring in the future. This will enhance the stability of the application.

Test Dependency Verification Prompt

Please provide a session-opening constraint for the project titled [PROJECT TITLE]. Use the following format: 'Before running tests: verify all dependencies are installed and up-to-date. If any are missing, stop and notify the user before continuing.' Ensure the response is clear and concise, suitable for inclusion in project documentation.

Prevent Recurrence

Test Consistency Check Template

Please create a conversation-starter template for conducting test consistency checks. The template should include a checklist that states: 'Before any test run, confirm that all test cases follow the naming convention [SPECIFIC CONVENTION]. If any test cases do not adhere to this convention, stop the process and notify the user immediately.' Ensure the template is clear and easy to follow.

Prevent Recurrence

Test Structure Enforcement Message

Draft a project specification message that enforces the structure of tests in our codebase. The message should clearly state that all tests must adhere to the following format: 'describe([TEST NAME], () => { it([TEST CASE], () => { [ASSERTIONS] }); });' Additionally, specify that any deviations from this structure will be flagged for review. Ensure the message is concise yet informative, providing context on the importance of maintaining this structure for code quality and consistency.

Prevent Recurrence

Test Output Validation Constraint

Please write a detailed constraint for validating test outputs in the context of preventing recurrence of bolt-breaking issues. Use the following format: 'All tests must produce outputs that match the expected format: [SPECIFIC FORMAT]. If the outputs do not match, flag the test as invalid and provide a brief explanation of the discrepancy.' Ensure the constraint is clear and actionable.

Prevent Recurrence

Pre-Run Test Check Request

Please create a self-check request for the agent to execute prior to running tests. The request should include the following steps: first, verify that all test cases are passing. If any failures are detected, report them immediately. Format the output as a clear checklist that the agent can follow to ensure all conditions are met before proceeding with the tests.

Prevent Recurrence

Frequently asked questions

Why do my tests fail after changes?+

Tests may fail due to changes in the code that violate existing assumptions. Bolt's sandboxed environment can sometimes mask these issues until the tests are run, revealing unexpected dependencies or logic errors.

How can I identify what caused a test failure?+

You can identify the cause of a test failure by reviewing the output from the last test run in Bolt. This output will indicate which test failed and provide an error message that can guide your debugging efforts.

What should I do if a test fails silently?+

If a test fails silently, check the console output for any hidden errors. Bolt may not surface all errors directly, so ensure to look for any warnings or logs that could indicate where the failure occurred.

How does Bolt handle test dependencies?+

Bolt manages dependencies in a sandboxed environment, which can lead to issues if dependencies are not correctly installed or updated. Always verify that all required dependencies are present before running tests.

What are common reasons for test failures in Bolt?+

Common reasons for test failures in Bolt include changes to the database schema, incorrect function signatures, or missing imports. Each of these can lead to tests failing unexpectedly if not properly managed.