question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot run unit tests on components with imports

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
abhilashdonepudicommented, Oct 3, 2018

Can we reopen this issue ?

We have the same issue. We are using Vuetify and have the following plugin. Any insight ?

"plugins": [
        [
            "transform-imports",
            {
                "vuetify": {
                    "transform": "vuetify/es5/components/${member}",
                    "preventFullImport": true
                }
            }
        ]
    ]
2reactions
sodateacommented, Nov 30, 2018

Please open a new issue with a reference to this one if you can follow up with more information.

Please also provide a runnable reproduction repo.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot run unittest in PyCharm [duplicate] - Stack Overflow
Python comes bundled with unittest: Your code is missing main method. import unittest class MyTest(unittest.TestCase): def test(self): self.
Read more >
Unit tests can't find imports when running under PyCharm
When I right-click a unit test case class and choose to run it as a unit test, it can't find my packages. Running...
Read more >
Basics of testing components - Angular
Test a component class on its own as you would test a service class. Component class testing should be kept very clean and...
Read more >
Test a .NET class library using Visual Studio - Microsoft Learn
Learn how to use Visual Studio to create and run a unit test project for a .NET class library. ... It imports the...
Read more >
Running Tests | Create React App
We recommend to put the test files (or __tests__ folders) next to the code they are testing so that relative imports appear shorter....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found