Debugging Jest Failure from Vue/Apollo GraphQL Error
TL;DR
- Jest test failing with unexpected ‘Vue warn’ console error about undefined ’nodeType’ property
- Suspect the issue stems from an upstream GraphQL query being improperly formatted or a backend issue causing a bad response
- Noticed related errors above indicating a query-specific error occurred before the nodeType issue
- Considering adding an ’error’ lifecycle method to the Apollo query in the Vue component to debug further
The Problem
I’m seeing an ‘Unexpected calls to console’ Jest failure accompanied by a Vue warn error stating that ’nodeType’ is not defined on the instance but is referenced during render. This looks like a downstream symptom of an upstream issue—possibly a GraphQL query that’s improperly formatted, or a backend problem causing a bad return that the frontend then fails to parse.
Reasoning
I suspect this because I see errors occurring above that state an error happened for a specific query, referencing the query name where it occurred.
Potential Fix
I’m considering adding the error lifecycle method to the Apollo query configuration in the Vue component, like: apollo: { configuredItems: { query: aiCatalogConfiguredItemsQuery, variables() {…}, update: (data) => data.aiCatalogConfiguredItems.nodes, result({ data }) { this.pageInfo = data.aiCatalogConfiguredItems.pageInfo; }, error(err) { console.debug(err); } } }, to help surface what’s actually going wrong.
ryer.io