这是我使用 MockedProvider 的方式。如何在模拟数组中模拟重新获取?
const mocks = [{
request: {
query: GET_USERS_BY_FACILITY,
variables: {
facility: 300
}
},
result: {
data: {
GetUsersByFacility: [{
nuId: 'Q916983',
userName: faker.internet.userName(),
profileKey: 'testKey',
profileValue: 'testValue',
__typename: 'FacilityUser'
}]
}
},
refetch: () => {
return {
data: {
GetUsersByFacility: [{
nuId: 'Q916983',
userName: faker.internet.userName(),
profileKey: 'testKey',
profileValue: 'testValue',
__typename: 'FacilityUser'
}]
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
该测试用例在触发删除事件时调用 refetch 函数。
it('should be able to click on delete user', async () => {
const {getByTestId} = render( …Run Code Online (Sandbox Code Playgroud)