Skip to content

Instantly share code, notes, and snippets.

@ykpoh
Created July 24, 2021 05:08
Show Gist options
  • Save ykpoh/ba60b025d3cc84db0973d8476b109a88 to your computer and use it in GitHub Desktop.
Save ykpoh/ba60b025d3cc84db0973d8476b109a88 to your computer and use it in GitHub Desktop.
import Foundation
import XCTest
extension Data {
public static func fromJSON(fileName: String) throws -> Data {
let bundle = Bundle(for: TestBundleClass.self)
let url = try XCTUnwrap(bundle.url(forResource: fileName, withExtension: "json"))
return try Data(contentsOf: url)
}
}
private class TestBundleClass { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment