(ast: {errors: ParseError[]}, message: string, errorCount?: number)
| 1824 | } |
| 1825 | |
| 1826 | function expectError(ast: {errors: ParseError[]}, message: string, errorCount?: number) { |
| 1827 | if (errorCount != null) { |
| 1828 | expect(ast.errors.length).toBe(errorCount); |
| 1829 | } else { |
| 1830 | expect(ast.errors.length).toBeGreaterThan(0); |
| 1831 | } |
| 1832 | |
| 1833 | for (const error of ast.errors) { |
| 1834 | if (error.msg.indexOf(message) >= 0) { |
| 1835 | return; |
| 1836 | } |
| 1837 | } |
| 1838 | const errMsgs = ast.errors.map((err) => err.msg).join('\n'); |
| 1839 | throw Error( |
| 1840 | `Expected an error containing "${message}" to be reported, but got the errors:\n` + errMsgs, |
| 1841 | ); |
| 1842 | } |
| 1843 | |
| 1844 | function expectActionError(text: string, message: string, errorCount?: number) { |
| 1845 | expectError(validate(parseAction(text)), message, errorCount); |
no test coverage detected
searching dependent graphs…