Hi, i’m trying to generate the tests mocks, using Apollo in order to write a few unit tests for my app, i just can’t understand how to setup my project in order to be able to do this, i added a screenshot from my apollo-codegen-config.json.
When i try to generate my files without filling the testMocks section it work perfectly fine but when i’m adding the SPM section and the targetName i got this error :
Error: typeMismatch(ApolloCodegenLib.ApolloCodegenConfiguration.TestMockFileOutput, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: “output”, intValue: nil), CodingKeys(stringValue: “testMocks”, intValue: nil)], debugDescription: “Invalid number of keys found, expected one.”, underlyingError: nil))
The key for your test mocks should be swiftPackage
not swiftPackageManager
, like this:
"testMocks" : {
"swiftPackage" : {
"targetName": "MockApollo"
}
}
Your moduleType
under schemaTypes
must also be set to swiftPackageManager
for this to work. You can read more about this in the documentation here.
1 Like
Thank you so much man, it’s working now
True Hero