FileMock is a web application that generates perfect test files for your development and testing needs. This quick start guide gets you up and running in 5 minutes.
What is FileMock?
FileMock generates realistic test files directly in your browser - completely client-side with instant file generation for comprehensive testing.
Perfect for:
- Unit test fixtures
- E2E testing scenarios
- Performance testing with large files
- Edge case validation
- Security testing with malformed files
Step 1: Access FileMock
- Visit filemock.com
- No signup required - start generating files immediately
- 100% client-side - your data never leaves your browser
Step 2: Generate Your First Test File
Basic Image Generation
- Select file type: Choose "Image" from the format selector
- Set properties:
- Size: 500KB (good for basic testing)
- Format: JPEG
- Dimensions: 1200x800px
- Click "Generate File"
- Download the generated file to your project
Advanced Options
FileMock offers powerful customization:
File Size Options:
├── Tiny (1KB - 10KB) - Icon testing
├── Small (10KB - 100KB) - Thumbnail testing
├── Medium (100KB - 1MB) - Standard uploads
├── Large (1MB - 10MB) - Performance testing
└── Huge (10MB+) - Stress testing
Step 3: Organize Your Test Files
Recommended Folder Structure
your-project/
├── tests/
│ └── fixtures/
│ └── filemock-files/
│ ├── images/
│ │ ├── valid-small.jpg
│ │ ├── valid-large.png
│ │ └── invalid-corrupted.jpg
│ ├── documents/
│ │ ├── small-pdf.pdf
│ │ └── large-docx.docx
│ └── edge-cases/
│ ├── empty-file.txt
│ ├── oversized.jpg
│ └── malformed.pdf
File Naming Convention
Use descriptive names that indicate purpose:
# Good naming examples
filemock-valid-jpeg-500kb.jpg
filemock-oversized-image-15mb.png
filemock-corrupted-pdf.pdf
filemock-empty-document.docx
# Include in filename:
- filemock- prefix (identifies source)
- purpose (valid/invalid/oversized)
- format (jpeg/png/pdf)
- size (500kb/15mb)
Step 4: Integration Examples
Jest Integration
// tests/fileUpload.test.js
import fs from "fs";
import path from "path";
const loadFileMockFile = (filename) => {
const filePath = path.join(__dirname, "fixtures/filemock-files", filename);
const buffer = fs.readFileSync(filePath);
return new File([buffer], filename, { type: "image/jpeg" });
};
test("handles FileMock generated files", () => {
const testFile = loadFileMockFile("filemock-valid-jpeg-500kb.jpg");
expect(testFile.size).toBe(512000); // 500KB
expect(testFile.type).toBe("image/jpeg");
});
Cypress Integration
// cypress/e2e/fileUpload.cy.js
describe("File Upload with FileMock", () => {
it("uploads FileMock generated file", () => {
cy.visit("/upload");
// Use FileMock generated file
cy.get('[data-testid="file-input"]').selectFile("cypress/fixtures/filemock-files/filemock-valid-jpeg-500kb.jpg");
cy.get('[data-testid="upload-button"]').click();
cy.contains("Upload successful").should("be.visible");
});
});
Step 5: Testing Scenarios with FileMock
Comprehensive Test Suite
Generate files for different scenarios:
1. Happy Path Testing
# Generate standard files
- 100KB JPEG image
- 2MB PNG image
- 500KB PDF document
2. Edge Case Testing
# Generate boundary cases
- 1KB minimum file
- 10MB maximum file
- Empty file (0 bytes)
3. Error Scenario Testing
# Generate problematic files
- Oversized file (exceeds limits)
- Corrupted file structure
- Wrong file extension
4. Performance Testing
# Generate load testing files
- 50MB large image
- 100MB video file
- Multiple 5MB files
Pro Tips
Batch Generation Workflow
- Plan your test scenarios first
- Generate all files in one FileMock session
- Download and organize immediately
- Document file purposes in your test comments
File Management
// Create a FileMock file registry
const FILEMOCK_FILES = {
validImage: "filemock-valid-jpeg-500kb.jpg",
largeImage: "filemock-large-png-5mb.png",
invalidFile: "filemock-corrupted-image.jpg",
oversizedFile: "filemock-oversized-15mb.jpg",
};
// Use in tests
const testFile = loadFileMockFile(FILEMOCK_FILES.validImage);
Version Control
# Include FileMock files in git for team consistency
git add tests/fixtures/filemock-files/
git commit -m "Add FileMock test files for upload testing"
Next Steps
- Explore Advanced Features: Try different file formats and sizes
- Build Test Suites: Create comprehensive test scenarios
- Team Integration: Share FileMock files with your team
- Automate: Include FileMock file generation in your CI/CD workflow
Common Use Cases
Frontend Testing
- Upload component validation
- File preview functionality
- Drag & drop interactions
- Progress indicator testing
Backend Testing
- File processing endpoints
- Storage integration
- File validation logic
- Performance under load
Security Testing
- Malicious file detection
- File type validation
- Size limit enforcement
- Content scanning
FileMock makes it easy to test all these scenarios with realistic, consistent test data generated instantly in your browser.
