Skip to content

Mocha unit test error with graphql: Can't reexport the named export 'graphql' from non EcmaScript module #1637

@renyuanz

Description

@renyuanz

Version

3.0.0-rc.3

Reproduction link

https://github.com/renyuanz/vue-cli-graphql-mocha-issue

Steps to reproduce

  • vue create graphql-bug
  • Choose Unit test with Mocha
  • Add graphql yarn add graphql
  • Import graphql in HelloWorld.spec.js
import { expect } from 'chai'
import { shallowMount } from '@vue/test-utils'
import { graphql } from 'graphql'
import HelloWorld from '@/components/HelloWorld.vue'

describe('HelloWorld.vue', () => {
  it('renders props.msg when passed', () => {
    const t = graphql();
    const msg = 'new message'
    const wrapper = shallowMount(HelloWorld, {
      propsData: { msg }
    })
    expect(wrapper.text()).to.include(msg)
  })
})

What is expected?

should run correctly

What is actually happening?

Failed to compile with 164 error(s)

Error in ./node_modules/graphql/index.mjs

  Can't reexport the named export 'BREAK' from non EcmaScript module (only default export is available)

// ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions