- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试使用 Typescript 为现有的 Vue 项目添加单元测试。我遵循了 vue-test-utils for typescript 的说明(https://vue-test-utils.vuejs.org/zh/guides/using-with-typescript.html)。但是,当我运行测试时,出现以下错误:TypeError:无法解构“undefined”或“null”的属性“polyfills”。处理预设时:
我尝试过的:我尝试重新安装babel-core等babel的依赖。重新检查配置。不工作。
我试图移除组件的安装,错误消失了。安装组件似乎存在一些问题。
这是我试过的小示例代码:
//component
<template>
<div>{{msg}}</div>
</template>
<script lang="ts">
export default {
name: "HelloWorld",
props: {
msg: String
}
};
</script>
//spec.ts
import { shallowMount } from '@vue/test-utils'
import HelloWorld from '../HelloWorld.vue'
describe('HelloWorld.vue', () => {
test('renders props.msg when passed', () => {
const msg = 'new message'
const wrapper = shallowMount(HelloWorld, {
propsData: { msg }
})
expect(wrapper.text()).toMatch(msg)
})
})
我对那里的错误堆栈有点困惑。有什么问题我可以解决吗?
最佳答案
我能够通过显式添加 babel-core@7.0.0-bridge.0
依赖项来解决这个问题(我的项目最初使用 babel-core@6.26.3
) 并重新生成我的 node_modules
目录。
在按照相同的指南尝试将 Jest 添加到现有项目后,我最初看到了这个错误和 Plugin 0 specified in ... provided an invalid property of "default"
。
在启用 TypeScript 和 Jest 的情况下从头开始创建一个新的 Vue 项目有助于了解需要更新版本的 Babel。另见 https://github.com/vuejs/vue-cli/issues/1131 .
关于typescript - 使用 Typescript 为 Vue 项目设置单元测试失败,出现 TypeError : Cannot destructure property `polyfills` of 'undefined' or 'null' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56462456/
有 destructuring-bind 但似乎没有 destructuring-setq。是否可以使用 destructuring-bind 来定义它? (let (a b c d) (dest
我遇到了一个我无法解决的丑陋问题。我是 React 的初学者。 这是我的代码 handleCheckChildElement(event) { let items = this.state.i
在 React 项目中,我想通过在特定时间记录特定状态部分来快速解决问题。 console.error('this.state.thing', this.state.thing); 这样做,我的 ES
hylang 是否像 clojure 中那样支持映射解构? 例如:https://gist.github.com/john2x/e1dca953548bfdfb9844#maps 最佳答案 Hy 没有
我正在尝试解构绑定(bind),如下所示: (destructuring-bind (a b) '(1 2) (list a b))) 当我在 REPL 中评估它时,我得到:
我已启用 SeriLog(最新版本)自记录功能,并且看到数百条消息说 Maximum destructuring depth reached 不知道这意味着什么以及这是否是我需要担心的问题。 有谁知道
我正在编写一个小型 React Native 应用程序,并且正在尝试使用 Flow,但我无法在任何地方真正获得有关它的正确教程。 我不断收到错误:关于此代码第一行中的 ({ station }) 的解
在 modules 文件夹中设置 redux 文件: \modules \application \actions application.js
我收到 JavaScript 错误 "missing = in destructuring declaration" 可能是什么问题? 最佳答案 这不是标准的 JavaScript 错误。它来自您的编
我正在使用一些像这样的解构: const { item } = content console.log(item) 但是我应该如何处理 content === undefined - 这会引发错误?
法拉第扫描函数的来源( https://github.com/ptaoussanis/faraday/blob/master/src/taoensso/faraday.clj#L1197 )有一个我正
我应该如何重写以下行以避免出现此错误 ctrl.formData.type = ctrl.types[0]; 最佳答案 根据 prefer-destructuring docs 调整规则配置应该避免这
有没有办法把下面的代码写得短一些? const { user } = JWT.verify(req.params.token, keys.secretOrKey); const { email } =
以下代码: export const myFunction = ({ option1, option2 }) => {}; ...给出: destructuring. Missing annotati
我有这个功能: const calculateTotal = (items) => { return items.reduce((totalPrice, basketItem) => {
我试图将应用程序下的所有组件包装在一个上下文中以提供我想要的东西 (如您所见,这是我的 UserContext 组件) enter code here import React, { useStat
这段代码有什么问题吗? class App extends React.Component { constructor(props) { super(props); this.st
我正在尝试编写一个宏,该宏扩展为具有解构的 let 形式。我的问题是我想拥有以 let 形式定义的符号列表,包括通过解构获得的符号列表。 用例 我试图排除这种行为,例如验证: (let [a (foo
嘿,我有这样的 uiTypes.js 文件: export default { SELECT_ITEM: 'SELECT_ITEM', DESELECT_ITEM: 'DESELECT_ITE
刚刚开始使用 Flow,但似乎无法理解它希望我为解构对象(例如 props)添加类型来做什么 即 render({ count }, { displayHelp }) { 抛出类似的错误 16:
我是一名优秀的程序员,十分优秀!