This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I have a component structure that is like:
BirthdaysWidget
BirthdaysToday
BirthdaysNotToday
The widget conditionally renders one or the other. When I try to run my test file, which looks like this:
import { mount } from '@vue/test-utils';
import BirthdaysWidget from '../BirthdaysWidget.vue';
import BirthdayToday from '../BirthdaysToday.vue';
import BirthdayNotToday from '../BirthdayNotToday';
describe('BirthdaysWidget.vue', () => {
test('default test', () => {
const wrapper = mount(BirthdaysWidget, {
slots: {
default: [BirthdayToday, BirthdayNotToday]
}
})
console.log(wrapper);
expect(1).toEqual(1);
});
});
Then I receive the following error:
● Test suite failed to run
Cannot find module './BirthdayToday' from 'BirthdaysWidget.vue'
37 |
38 | <script>
> 39 | import BirthdayToday from './BirthdayToday'
| ^
40 | import BirthdayNotToday from './BirthdayNotToday'
41 |
42 | export default {
I've had a google about and not had any luck in finding a definitive answer that has worked for me so far.
I just want to test the methods at the moment in my components, but I'm not sure how I can make my test file recognise the child components. I presume it has something to do with the paths I'm using to import the files in the actual Vue component
Subreddit
Post Details
- Posted
- 6 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/vuejs/comme...