Gomah / nuxt-graphql-request

Easy Minimal GraphQL client integration with Nuxt.js.
https://nuxt-graphql-request.vercel.app
MIT License
196 stars 16 forks source link

Get error when call fetchSomething in beforeMount when test with jest #41

Closed silvesterwali closed 1 year ago

silvesterwali commented 2 years ago
<script>
import { gql } from 'nuxt-graphql-request';

export default {
beforeMount(){
  this.fetchSomething()
},
  methods: {
    async fetchSomething() {
      const query = gql`
        {
          Movie(title: "Inception") {
            releaseDate
            actors {
              fullname # "Cannot query field 'fullname' on type 'Actor'. Did you mean 'name'?"
            }
          }
        }
      `;

      try {
        const data = await this.$graphql.default.request(endpoint, query);
        console.log(JSON.stringify(data, undefined, 2));
      } catch (error) {
        console.error(JSON.stringify(error, undefined, 2));
        process.exit(1);
      }
    },
  },
};
</script>

image

hi there.. i just got this error when test using jest . my test just like below image

the #graphql.default is not undefined in test mode ..but running di developer process. thanks for any feedback