Skip to content

trevonerd/flakify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

⚡ Flakify

Unmask flaky tests with style

A powerful CLI tool to detect flaky tests by running them multiple times with beautiful real-time progress tracking and detailed failure analysis.

npm version License: MIT

🎯 Why Flakify?

Flaky tests are a nightmare. They pass sometimes and fail other times, making your CI/CD unreliable. Flakify helps you identify these tests by running them multiple times and tracking their behavior.

✨ Features

  • 🔄 Run tests multiple times - Sequential or parallel execution
  • 📊 Real-time progress tracking - Watch your tests run with live stats
  • 🎨 Beautiful UI - Animated spinners and color-coded results
  • 📝 Detailed failure reports - See exactly which tests failed, in which file, and at which line
  • 🎯 Flaky test detection - Automatically identifies tests that pass sometimes and fail other times
  • 🚀 Works with any test runner - Jest, Vitest, Mocha, and more

📦 Installation

npm install -g flakify

🚀 Usage

Basic Usage

Run your tests multiple times:

flakify "yarn test" 10

Parallel Mode

Run tests in parallel for faster execution:

flakify "npm test" 5 --parallel

Real Examples

# Run Jest tests 10 times
flakify "yarn test" 10

# Run Vitest tests 20 times in parallel
flakify "yarn test:storybook" 20 --parallel

# Run specific test file 5 times
flakify "npm test -- Button.test.ts" 5

📖 Output Example

╔═══════════════════════════════════════════════════════════╗
║  ⚡ Flakify - Unmask Flaky Tests                           ║
╚═══════════════════════════════════════════════════════════╝

Command: yarn test
Runs: 10
Mode: → Sequential

  ✓ Run #1: Passed [147/147 files 560/560 tests]
  ✓ Run #2: Passed [147/147 files 560/560 tests]
  ⠹ Run #3: Running 5.3s [45/147 files]
  ○ Run #4: Pending
  ...

╔═══════════════════════════════════════════════════════════╗
║  Summary                                                  ║
╚═══════════════════════════════════════════════════════════╝

  ✓ Passed:       7/10
  ✗ Failed:       3/10
  ◈ Success Rate: 70.00%
  ⏱  Duration:     182.50s

🔥 FLAKY TEST DETECTED!

Failed Tests by Run:

Run #4:
  ✗ Button should handle click events
    src/components/Button.test.ts:42

Unique Failed Tests:
  ✗ Button should handle click events
    File: src/components/Button.test.ts:42
    Failed in run(s): 4, 7, 9

💡 Tip: yarn test src/components/Button.test.ts

🎛️ Options

Option Description Default
<command> Test command to run (in quotes) Required
<times> Number of times to run Required
--parallel Run tests in parallel Sequential

🧪 Supported Test Runners

  • ✅ Jest
  • ✅ Vitest
  • ✅ Mocha
  • ✅ Any test runner that outputs to stdout

💡 Tips

Finding the Perfect Number of Runs

  • 5-10 runs: Quick check for obvious flakiness
  • 20-50 runs: Thorough investigation
  • 100+ runs: Extreme cases or CI environment testing

Sequential vs Parallel

  • Sequential (default): Safer, prevents resource contention, easier to debug
  • Parallel (--parallel): Faster, good for independent tests, may stress system resources

Best Practices

  1. Start with sequential mode to understand the flakiness pattern
  2. Use parallel mode once you've identified the problematic tests
  3. Run flaky tests in isolation to debug more easily
  4. Fix root causes (timing issues, shared state, race conditions)

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

MIT © Marco Trevisani

🙏 Acknowledgments

Built with love to make testing more reliable for everyone.


Made with ⚡ by Marco Trevisani

About

Unmask flaky tests by running them multiple times with beautiful real-time feedback

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published