我有这种输入类型,我想在其中一个字段中添加一个默认值.我想在ExampleInput中的值字段中添加0.
type ExampleType {
value: Int
another: String
}
type Mutation {
example(input: ExampleInput): ExampleType
}
input ExampleInput {
value: Int
another: String
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
// MyComponent.jsx
const MyComponent = (props) => {
const { fetchSomeData } = props;
useEffect(()=> {
fetchSomeData();
}, []);
return (
// Some other components here
)
};
// MyComponent.react.test.jsx
...
describe('MyComponent', () => {
test('useEffect', () => {
const props = {
fetchSomeData: jest.fn(),
};
const wrapper = shallow(<MyComponent {...props} />);
// THIS DOES NOT WORK, HOW CAN I FIX IT?
expect(props.fetchSomeData).toHaveBeenCalled();
});
});
Run Code Online (Sandbox Code Playgroud)
运行测试时,我得到:
expect(jest.fn()).toHaveBeenCalled()
Expected mock function to have been called, but it was not called.
Run Code Online (Sandbox Code Playgroud)
期望失败,因为 …
我试图通过名为 的 redux 操作重置状态resetState,其中我将状态分配给initialState变量,但这不起作用。
const initialState = {
someArray: [],
someEvents: {}
}
const stateSlice = createSlice({
name: "someState",
initialState,
reducers: {
...someActions,
resetState: (state, action) => {
// THIS DOES NOT WORK
state = initialState
},
resetState2: (state, action) => {
// THIS WORKS!!!!
return initialState
},
});
Run Code Online (Sandbox Code Playgroud)
当我返回初始状态时,状态会正确重置,但将其分配给initialState不会。
目前我有最新版本2.2.17,我想降级到版本2.2.12。
Brew 没有选项downgrade,只有一个upgrade. brew是不是卸载重装的过程?