MCPcopy
hub / github.com/codeceptjs/CodeceptJS / hopeThat

Function hopeThat

lib/effects.js:122–163  ·  view source on GitHub ↗
(callback)

Source from the content-addressed store, hash-verified

120})
121
122async function hopeThat(callback) {
123 if (store.dryRun) return
124 const sessionName = 'hopeThat'
125
126 let result = false
127 return recorder.add(
128 'hopeThat',
129 () => {
130 recorder.session.start(sessionName)
131 store.hopeThat = true
132 callback()
133 recorder.add(() => {
134 result = true
135 recorder.session.restore(sessionName)
136 return result
137 })
138 recorder.session.catch(err => {
139 result = false
140 const msg = err.inspect ? err.inspect() : err.toString()
141 output.debug(`Unsuccessful assertion > ${msg}`)
142 hopeThatFailures.push(msg)
143 event.dispatcher.once(event.test.finished, test => {
144 if (!test.notes) test.notes = []
145 test.notes.push({ type: 'conditionalError', text: msg })
146 })
147 recorder.session.restore(sessionName)
148 return result
149 })
150 return recorder.add(
151 'result',
152 () => {
153 store.hopeThat = undefined
154 return result
155 },
156 true,
157 false,
158 )
159 },
160 false,
161 false,
162 )
163}
164
165/**
166 * Asserts that no `hopeThat` soft assertion has failed in the current test.

Callers 3

effects_test.jsFile · 0.90

Calls 6

callbackFunction · 0.85
debugMethod · 0.80
pushMethod · 0.80
addMethod · 0.45
startMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected