TL;DR
Black box testing checks how your web app works without looking at the code. Focus on inputs, outputs, and expected behaviour. This guide shows you practical steps for JavaScript MVC apps.
1. Understand Your App’s Features
- List all features: Make a complete list of everything your app does. Think about user stories – what can users achieve? (e.g., ‘User can log in’, ‘Admin can add products’).
- Identify inputs: For each feature, note down every possible input the user can provide. This includes form fields, URL parameters, button clicks, and even file uploads.
- Define expected outputs: What should happen after each input? (e.g., ‘Successful login redirects to dashboard’, ‘Invalid password shows error message’).
2. Test the Core MVC Components
JavaScript MVC apps typically have three main parts: Models, Views, and Controllers.
2.1 Model Testing
- Data validation: Check that models correctly validate data before saving it. Try invalid inputs (e.g., too short passwords, incorrect email formats).
- Database interaction: Verify the model saves and retrieves data from the database as expected. You might need to inspect the database directly after testing.
- Example: If you have a User model with an email field:
// Example validation check (using a hypothetical framework)const user = new User({ email: 'invalid-email' });if (!user.isValid()) {console.error('Email is invalid');