Swiftpack.co -  azsn/URLSessionMock as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Utilities for mocking network endpoints for unit tests in Swift
.package(url: "https://github.com/azsn/URLSessionMock.git", from: "v0.1.0")


A mock for Swift's URLSession network request class, allowing unit tests to mock responses from API endpoints without any real network access. Any type of server response can be mocked, but currently this package focuses on HTTP endpoints. In addition, this package contains some related utility functions that may be useful in unit tests using URLSessionMock.

Usage example:

// Test setup
let session = URLSession.mock
let url = URL(string: "https://example.com")
let mock = BasicEndpointMock(status: 404)
URLSession.mockEndpoints = [url: mock]

// Production code to test
session.dataTask(with: url) { (data, response, error) in
	// response is a HTTPURLResponse with 404 status




Stars: 1
Last commit: 33 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

33 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics