| 35 | } |
| 36 | |
| 37 | const expectTestToFail = async (callback, error) => { |
| 38 | if (callback.length > 0) { |
| 39 | throw Error( |
| 40 | 'Gated test helpers do not support the `done` callback. Return a ' + |
| 41 | 'promise instead.', |
| 42 | ); |
| 43 | } |
| 44 | try { |
| 45 | const maybePromise = callback(); |
| 46 | if ( |
| 47 | maybePromise !== undefined && |
| 48 | maybePromise !== null && |
| 49 | typeof maybePromise.then === 'function' |
| 50 | ) { |
| 51 | await maybePromise; |
| 52 | } |
| 53 | } catch (testError) { |
| 54 | return; |
| 55 | } |
| 56 | throw error; |
| 57 | }; |
| 58 | |
| 59 | const gatedErrorMessage = 'Gated test was expected to fail, but it passed.'; |
| 60 | global._test_gate = (gateFn, testName, callback) => { |