(actual: T)
| 117 | function when(s: string) { console.log(` When ${s}`) } |
| 118 | function then(s: string) { console.log(` Then ${s}`) } |
| 119 | function expect<T>(actual: T) { |
| 120 | return { |
| 121 | toBe(expected: T, label = "value") { |
| 122 | if (actual !== expected) throw new Error( |
| 123 | `${label}: expected ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`) |
| 124 | }, |
| 125 | toBeTruthy(label = "value") { |
| 126 | if (!actual) throw new Error(`${label}: expected truthy, got ${JSON.stringify(actual)}`) |
| 127 | }, |
| 128 | toMatch(re: RegExp, label = "value") { |
| 129 | if (typeof actual !== "string" || !re.test(actual)) |
| 130 | throw new Error(`${label}: expected to match ${re}, got ${JSON.stringify(actual)}`) |
| 131 | }, |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | // Specialized assertion for action results — if the action failed, includes |
| 136 | // the full fail.code + message in the error so we don't have to guess. |
no outgoing calls
no test coverage detected