Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module '../BlogPost.vue' or its corresponding type declarations. #8

Open
Mnigos opened this issue Jan 25, 2021 · 2 comments

Comments

@Mnigos
Copy link

Mnigos commented Jan 25, 2021

I have some problem with importing component I have test file in the same folder as component.

BlogPost.spec.ts

import 'jest';
import { shallowMount } from '@vue/test-utils';
import BlogPost from './BlogPost.vue';

describe('BlogPost Component', () => {
  it('Displaying posts from data', () => {
    const title = 'New Title';
    const wrapper = shallowMount(BlogPost, {
      propsData: { title },
    });
    expect(wrapper.text()).toMatch(title);
  });
});

BlogPost.vue

<template>
  <div class="d-flex flex-column align-center">
    <div class="rounded-xl blog-post">
      <v-row>
        <v-col>
          <div class="d-flex justify-center">
            <h1>{{ title }}</h1>
          </div>
          <div class="d-flex justify-center">
            <v-img :src="image" />
          </div>
          <div class="d-flex justify-center">
            {{ description }}
          </div>
        </v-col>
      </v-row>
    </div>
  </div>
</template>

<script lang="ts">
import Vue from 'vue';

export default Vue.extend({
  name: 'BlogPost',
  props: {
    title: String,
    image: String,
    description: String,
    date: Date,
  },
});
</script>
@cmauf
Copy link

cmauf commented Mar 6, 2022

What seems to be the problem? Some error output would be helpful.

@chris-verclytte
Copy link

chris-verclytte commented Aug 21, 2024

Having the same here.

The error is something like (changed the names to match above example) :

src/components/BlogPost.spec.ts:4:28 - error TS2307: Cannot find module './BlogPost.vue' or its corresponding type declarations.

It also states the same for '@'-prefixed paths (despite the moduleNameMapper being configured).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants