(ast: {errors: ParseError[]}, message: string, errorCount?: number)
| 2076 | } |
| 2077 | |
| 2078 | function expectError(ast: {errors: ParseError[]}, message: string, errorCount?: number) { |
| 2079 | if (errorCount != null) { |
| 2080 | expect(ast.errors.length).toBe(errorCount); |
| 2081 | } else { |
| 2082 | expect(ast.errors.length).toBeGreaterThan(0); |
| 2083 | } |
| 2084 | |
| 2085 | for (const error of ast.errors) { |
| 2086 | if (error.msg.indexOf(message) >= 0) { |
| 2087 | return; |
| 2088 | } |
| 2089 | } |
| 2090 | const errMsgs = ast.errors.map((err) => err.msg).join('\n'); |
| 2091 | throw Error( |
| 2092 | `Expected an error containing "${message}" to be reported, but got the errors:\n` + errMsgs, |
| 2093 | ); |
| 2094 | } |
| 2095 | |
| 2096 | function expectActionError(text: string, message: string, errorCount?: number) { |
| 2097 | expectError(validate(parseAction(text)), message, errorCount); |
no test coverage detected