Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. iOS
  3. Mockingjay

Mockingjay

BSD-3-ClauseSwift3.0.0-alpha.1

An elegant Swift library for stubbing HTTP requests in tests, compatible with NSURLConnection, NSURLSession, Alamofire, and AFNetworking.

GitHubGitHub
1.5k stars173 forks0 contributors

What is Mockingjay?

Mockingjay is a Swift library for stubbing HTTP and HTTPS requests during unit and integration tests. It allows developers to simulate network responses, errors, and status codes without making actual network calls, ensuring tests are fast, reliable, and isolated. It supports NSURLConnection, NSURLSession, and popular networking libraries like Alamofire and AFNetworking.

Target Audience

iOS and macOS developers writing tests in Swift who need to mock network requests for unit, integration, or UI testing. It's particularly useful for developers using XCTest or Quick.

Value Proposition

Developers choose Mockingjay for its elegant, extensible API, seamless integration with XCTest/Quick, and compatibility with major Swift networking libraries. It simplifies test setup with built-in matchers and builders while allowing custom extensions for complex scenarios.

Overview

An elegant library for stubbing HTTP requests with ease in Swift

Use Cases

Best For

  • Unit testing network-dependent Swift code without hitting real APIs
  • Simulating HTTP errors and edge cases in iOS/macOS tests
  • Mocking JSON API responses for UI testing with Alamofire
  • Isolating tests from network flakiness in CI/CD pipelines
  • Creating reusable test fixtures from JSON files
  • Stubbing dynamic URLs with URI template patterns

Not Ideal For

  • Projects using gRPC, WebSockets, or non-HTTP networking protocols
  • Teams needing detailed network condition simulation (e.g., latency, packet loss) beyond simple response stubbing
  • Applications relying heavily on real network integration tests where stubbing might mask API issues
  • SwiftUI codebases using modern async/await with URLSession, where newer libraries may offer tighter integration

Pros & Cons

Pros

Seamless XCTest Integration

Automatically unloads stubs after each test case, ensuring test isolation without manual cleanup, as highlighted in the README for both XCTest and Quick.

Flexible URI Template Matching

Supports dynamic URL patterns using URI templates, allowing stubbing for APIs with variable path segments like '/{user}/{repository}' without hardcoding URLs.

Extensible Closure-Based API

Enables custom matchers and builders through simple closures, making it adaptable to complex stubbing scenarios beyond the built-in functions like 'everything' or 'uri'.

Broad Library Compatibility

Works with Alamofire, AFNetworking, and any library using NSURLConnection or NSURLSession, covering most Swift networking libraries without extra configuration.

Cons

Limited to HTTP/HTTPS

Only supports stubbing for HTTP and HTTPS requests, making it unsuitable for testing other protocols like gRPC or WebSockets, which require separate tools.

No Native Swift Concurrency Support

The API is based on closures and doesn't explicitly integrate with Swift's async/await, requiring additional boilerplate for modern codebases using concurrent networking.

CocoaPods-Centric Installation

Installation documentation primarily recommends CocoaPods, which may be a barrier for teams exclusively using Swift Package Manager, though community support might exist.

Frequently Asked Questions

Quick Stats

Stars1,487
Forks173
Contributors0
Open Issues19
Last commit2 years ago
CreatedSince 2015

Tags

#unit-testing#alamofire#afnetworking#network-mocking#test-fixtures#swift#ios-testing

Built With

S
Swift

Included in

iOS51.7kSwift26.0k
Auto-fetched 1 day ago

Related Projects

SnapshotTestingSnapshotTesting

📸 Delightful Swift snapshot testing.

Stars4,256
Forks670
Last commit2 months ago
iOS Snapshot Test CaseiOS Snapshot Test Case

Snapshot view unit tests for iOS

Stars1,852
Forks227
Last commit6 months ago
FakeryFakery

:alien: Swift fake data generator

Stars1,829
Forks186
Last commit3 years ago
CuckooCuckoo

Boilerplate-free mocking framework for Swift!

Stars1,743
Forks197
Last commit10 days ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub