当我运行jest时,我会得到以下错误。看起来原因是与类型记录相关的,但是我在package.json中有一些类型记录处理,所以我不知道为什么它不会被处理。
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
...
Details:
/Users/ryancocuzzo/ex/test/example/mobile-a
我正在尝试使用jest-dom来测试组件的样式,但我遇到了错误:
"TypeError: expect(...).toHaveStyle is not a function"
我的组件是一个带有样式组件的简单链接:
import styled from 'styled-components'
export const Link = styled.a`
color: #fff;
`
在我的测试中,我做的是:
describe('Link', () => {
it('should display color on the li
假设我有组件,当调用render()时,组件被呈现,然后挂载到DOM节点上:
render() {
// Render the HTML elements
const content = renderParent();
// Mount onto the DOM element with id `app`;
let element = document.getElementById('app');
element.innerHTML = '';
element.appendChild(div);
}
renderParent(
我有一个非常简单的测试:
describe('sanity', () => {
it('sanity', () => {
expect(true).toBeTruthy()
})
})
我收到了以下错误:
FAIL spec/javascript/sanity_test.js
● Test suite failed to run
Jest encountered an unexpected token
This usually means that you are trying to import a fi