The problem is that instead of mocked I got a loading screen with unresolved query, Cypress make several attempts to re-query it again, and there is no error messages.
I'm using Cypress from Quasar-testing harness. I'd like to mock graphql
call.
In my component I have an apollo
query:
apollo: {
assetsOverview: {
query: ASSETS_OVERVIEW,
loadingKey: 'loading'
}
}
For that purpose I'm using fixtures in such way:
cy.intercept('POST', api, req => {
if (req.body.operationName === 'getAssetOverview') {
// This condition works just fine
req.reply({
fixture: 'asset-table.json'
})
}
})
My fixture looks like this:
{
"assetsOverview": {
"assetMetrics": [
{
"assetId": "todo-conveyor",
"assetName": "Conveyor belts",
"childAssetIds": null,
"oeeMetrics": {
"availability": null,
"oee": null,
"performance": null,
"quality": null,
"__typename": "AssetOeeMetrics"
},
"stateMetrics": {
"blocked": null,
"failed": null,
"idle": null,
"running": null,
"stopped": null,
"__typename": "AssetStateMetrics"
},
"__typename": "AssetMetrics"
}
],
"__typename": "AssetMetricsOverview"
}
}
Figured out that I have to wrap my fixtures object within data
.
Like this:
{
"data": {
"assetsOverview": {
"assetMetrics": [
...
]
}
}
}