测试Vue.js / TypeScript组件时的玩笑错误

时间:2018-11-30 14:04:30

标签: typescript vue.js jestjs

我使用vue cli 3创建了一个带有打字稿和玩笑的应用程序,用于单元测试。但是我遇到了这个错误

SyntaxError: Unexpected token m in JSON at position 0
        at JSON.parse (<anonymous>)

有什么难解? (我没有在jest.config或tsconfig中进行任何更改)

顺便说一句,如果将lang =“ ts”更改为lang =“ js”即可。

代码组件(可能是简化列表组件):

<template>
    <div>{{hello}}</div>
</template>

<script lang="ts">
import Vue from 'vue'
export default Vue.extend({
    data () {
        return {
            message: 'hello'
        }
    }
})
</script>

测试文件

import { shallowMount, Wrapper } from '@vue/test-utils';

import AComp from '@/components/uikit/AComp.vue';

describe('DropdownButton', () => {
    beforeEach(() => {
        const wrapper = shallowMount(AComp);
    });

    it("works", () => {
        expect(true).toBeTruthy()
    })
});

0 个答案:

没有答案
相关问题