A
A
Alexey Yarkov2018-05-03 23:25:20
Unit testing
Alexey Yarkov, 2018-05-03 23:25:20

Jest + TypeScript + Vue = crazy?

<template>
  <li>
    <a class="user-menu__link" @click.prevent="go(item.link)">{{item.text}}</a>
  </li>
</template>

<script lang="ts">
import script from './script'
export default script
</script>

<style lang="scss" scoped>
@import 'styles';
</style>

import Vue from 'vue'
import { Prop, Emit, Component } from 'vue-property-decorator'
import { IMenuItem } from '../types.d' // Убираю этот импорт и все гуд O_o

@Component
export default class ListItem extends Vue {
  @Prop({ type: Object, required: true })
  item: IMenuItem

  @Emit('go')
  go(path: string = '/') {
    this.$router.push({ path })
  }
}

Who works with Vue + TS + Jest ?
An incomprehensible cant when running Unit tests.
If you try to import any type in the Vue file, then the test fails with an error: Debug Failure. False expression: Output generation failed
Perhaps this is due to @vue/test-utils , since I'm testing mutations with pure Jest and there are no such problems.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2018-05-04
@yarkov

I solved it by renaming the types.d.ts file to types.ts .
The problem seems to be in jest-vue-preprocessor or @vue/test-utils (I haven't found it yet).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question