can change if error for a given response code6ms ‣
var originalResponseHandling = htmx.config.responseHandling
var errorDetected = false
var handler = htmx.on('htmx:responseError', function() {
errorDetected = true
})
try {
htmx.config.responseHandling = originalResponseHandling.slice()
htmx.config.responseHandling.unshift({ code: '444', swap: true, error: false })
var responseCode = null
this.server.respondWith('GET', '/test', function(xhr, id) {
xhr.respond(responseCode, { 'Content-Type': 'text/html' }, '' + responseCode)
})
responseCode = 444
var btn = make('<button hx-get="/test">Click Me!</button>')
btn.click()
this.server.respond()
btn.innerHTML.should.equal('444')
errorDetected.should.equal(false)
} finally {
htmx.off('htmx:responseError', handler)
htmx.config.responseHandling = originalResponseHandling
}