Coming soon - Get a detailed view of why an account is flagged as spam!
view details

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.

1
Jest can't find Child components?
Post Body

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

Author
Account Strength
100%
Account Age
13 years
Verified Email
Yes
Verified Flair
No
Total Karma
692,980
Link Karma
149,429
Comment Karma
541,007
Profile updated: 2 days ago
Posts updated: 7 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
6 years ago