A shared folder with AI prompts and code snippets
From workspace: Replit
Team: AI Prompts
Total snippets: 7
7 snippets
Add edge case tests for a sorting algorithm.
Add test cases for this sorting function. Cover: – Empty list – One item – Already sorted – Repeated values Code: def sort_numbers(arr): return sorted(arr)
Write test cases for an async function that fetches data.
Write Jest tests for this async function. Mock `fetch()` and test: – Successful fetch – 404 or error case – Bad JSON structure Code: async function fetchUser(id) { const res = await fetch(`/api/users/${id}`); const data = await...
Create unit tests for backend validation logic in a Node.js function.
Write unit tests using `Jest` for this validation function. Test cases: – Missing fields – Invalid email – Age < 18 – Valid input Code: function validateForm(data) { if (!data.email.includes('@')) return false; if (data.age < 18) return...
Write an integration test for a Flask endpoint using Flask's test client.
Write an integration test for this Flask route using `app.test_client()`. Test: – Valid credentials – Wrong credentials – Status codes – JSON response Code: @app.route('/login', methods=['POST']) def login(): data = request.get_json() if...
List test cases to validate behavior of SQL logic for edge input.
You are testing the following SQL query. List: – Input scenarios to test (e.g. totals = 100, NULLs) – Edge logic that may fail – Verification method for expected results Query: SELECT * FROM orders WHERE total > 100 AND status = 'confirmed';
Review a function and suggest missing test cases.
You are reviewing this function for test coverage. Identify: – Edge cases not covered – Unexpected or null input – Suggestions for improved testing Code: def format_price(value): if value is None: return "N/A" return...
Generate comprehensive unit tests for a given Python function using
You are given a Python function. Write unit tests using `pytest`. Cover: – Valid input – Invalid input – Edge cases (e.g. empty lists, negative numbers) – Exceptions and assertions Code: def divide_numbers(a, b): return a / b