WeTransfer / Mocker

Mock Alamofire and URLSession requests without touching your code implementation
MIT License
1.12k stars 96 forks source link

The "Empty Responses" example doesn't work: No exact matches in call to initializer #147

Closed DominikPalo closed 1 year ago

DominikPalo commented 1 year ago

I'm trying to mock empty responses according to the example provided in the readme file, but it seems the code snippet is not compatible with the latest version (3.0.1) of the framework. There is a line:

let mock = Mock(request: request, statusCode: 204)

which prevents Xcode from building the app, as there is no such initializer on the Mock structure: No exact matches in call to initializer

CSHawley commented 1 year ago

Noticed the same issue. How about using an empty Data object? Worked for me with Alamofire

let empty = Data()
let mock = Mock(url: url, dataType: .json, statusCode: 204, data: [.delete : empty])
mock.register()
github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 30 days with no activity. Remove the Stale label or comment or this will be closed in 10 days.