我正在尝试测试类似的功能:
function foo() {
return {
key_a: "val_a",
key_b: new Date()
};
Run Code Online (Sandbox Code Playgroud)
如何为这种情况制作预期的测试对象?
const expectedObject = {
key_a: "val_a",
key_b: new Date()
}
expect(foo()).toEqual(expectedObject)?
- Expected
+ Received
- "key_b": 2019-01-23T14:04:03.060Z,
+ "key_b": 2019-01-23T14:04:03.061Z,
Run Code Online (Sandbox Code Playgroud) 我正在尝试测试我的react组件的渲染,但是得到以下错误: 不变违例:_registerComponent(...):目标容器不是DOM元素. 如果我更改下面在document.body上渲染我的组件的位置,则不存在错误,如果此位置是某个div,并且在body中有一些id,则存在错误.
这是我的组件:
import React, {Component} from 'react';
{render} from 'react-dom';
import Demo from './demo/demo'
import Demo2 from './demo2/demo2'
require('./app-styles.sass')
export class App extends Component {
render() {
return (
<div>
<Demo2 />
<Demo />
<div>Hello jest from react</div>
</div>
);
}
}
render(<App/>, document.getElementById('helloWorldRoot'));
Run Code Online (Sandbox Code Playgroud)
测试这个组件:
import React from 'react'
import {shallow, mount} from 'enzyme'
import {App} from './app'
describe('base component', () => {
it('renders as a div', () => {
const application = shallow(<App />);
expect(application).toMatchSnapshot();
});
}); …Run Code Online (Sandbox Code Playgroud) 我正在尝试运行 android 模拟器,但不是成功,而是出现错误和滞后的 ui 错误:
handleCpuAcceleration: feature check for hvf
cannot add library /Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libvulkan.dylib: failed
added library /Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib
cannot add library /Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libMoltenVK.dylib: failed
HVF error: HV_ERROR
qemu-system-x86_64: failed to initialize HVF: Invalid argument
Failed to open the hax module
No accelerator found.
qemu-system-x86_64: failed to initialize HAX: Operation not supported by device
added library /Library/Android/sdk/emulator/lib64/vulkan/libMoltenVK.dylib
Run Code Online (Sandbox Code Playgroud)
我已经尝试了这篇文章Android Emulator 30.4.5 not working on MacOS 以及其他有关 stackoverflow 和 google 搜索结果的相关文章中推荐的所有步骤 ,但尚未成功。
Mac OS 大苏尔 11.2.3