typescript - 使用它来测试 vuejs/typescript 组件时的笑话错误
问题描述
我使用 vue cli 3 创建了一个带有 typescript 和 jest 的应用程序以进行单元测试。但我得到了这个错误
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()
})
});
解决方案
推荐阅读
- python - 从python中的列表中删除下一个元素
- java - 如何在 C/C++ 透视图中将鼠标悬停在一行代码上时显示自定义工具提示?
- java - 带有 MPAndroidChart/Charts 库的 Google Fit / Apple Health 条形图样式
- haskell - 如何从字符串中删除空格?
- lua - ROBLOX ProximinityPrompt 门无法打开或关闭
- mysql - Spring JDBC 无法插入
- php - 保存带有日期的图片
- gis - 在QGIS中提取多边形内外的最近点
- vba - 禁用列表框中的多选行、列表框中的格式化列,并在使用 vba 从文本框中清除搜索查询时填充列表框
- reactjs - 使用 react-native-view-pager 反应原生 PWA