Skip to content

Cannot run unit tests on components with imports #2296

@guilhermewaess

Description

@guilhermewaess

Version

3.0.1

Node and OS info

Node 10.4.1 / npm 6.1.0 / Windows 10

Steps to reproduce

Here go my steps:

Generated new project with vue-cli 3
Selected: Vuex, Router, Scss, Airbnb, Jest

On .vue component, when you import anything there is an error.

<script>
import Anything from 'AnyPath'; <------- Generates Error

export default {
  name: 'HelloWorld',
  props: {
    msg: String,
  },
};
</script>

Without imports, everything works as expected

<script>
export default {
  name: 'HelloWorld',
  props: {
    msg: String,
  },
};
</script>

What is expected?

Tests running without any problem.

What is actually happening?

FAIL tests/unit/HelloWorld.spec.js
● Test suite failed to run

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined

  at findOptionFromSource (node_modules/babel-plugin-transform-imports/index.js:22:46)
  at PluginPass.ImportDeclaration (node_modules/babel-plugin-transform-imports/index.js:85:27)
  at newFn (node_modules/@babel/traverse/lib/visitors.js:237:21)
  at NodePath._call (node_modules/@babel/traverse/lib/path/context.js:65:20)
  at NodePath.call (node_modules/@babel/traverse/lib/path/context.js:40:17)
  at NodePath.visit (node_modules/@babel/traverse/lib/path/context.js:100:12)
  at TraversalContext.visitQueue (node_modules/@babel/traverse/lib/context.js:142:16)
  at TraversalContext.visitMultiple (node_modules/@babel/traverse/lib/context.js:97:17)

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs reproductionThis issue is missing a minimal runnable reproduction, provided by the author

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions