Cannot run unit tests on components with imports
See original GitHub issueVersion
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:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Can we reopen this issue ?
We have the same issue. We are using Vuetify and have the following plugin. Any insight ?
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.