Testing the Bejeezus out of React Native Apps with AVA
Steve Kellock
13612

Question in regards to avaJS, generator ( saga ), and redux

login generator
export function * login ({ username, password, deviceTesting = null }) {
const deviceID = deviceTesting === null ? DeviceInfo.getDeviceId():'testdevice'
if (password === '') {
// dispatch failure
yield put(LoginActions.loginFailure({error_description: 'Please input a valid password'}))
} else {
// dispatch successful logins
try {
const data = {stuff...}
const fauxAPI = fauxAPI.signIn(data)
const response = yield call(fauxAPI._getSignIn)
// success?
console.log(response)
if (response.ok) {
yield put(LoginActions.loginSuccess(response.data))
} else {
yield put(LoginActions.loginFailure(response.data))
}
} catch (e) {
console.log(e)
}
}
}
// test code
const stepper = (fn) => (mock) => fn.next(mock).value
test('success', (t) => {
const mock = { username: 'a', password: 'b' }
const step = stepper(login(mock))

t.deepEqual(step(), put(LoginActions.loginSuccess(mock.username)))
})

If I call step() before going to the assertion I can see the call

{ ‘@@redux-saga/IO’: true,
 CALL: { context: null, fn: [Function: _getSignIn], args: [] } }

When the test finishes it just hangs indefinitely in AVA.js I was just wondering if you have any suggestions or advice thanks.