|
| 1 | +describe('problem matcher tests', () => { |
| 2 | + it('tsc: matches TypeScript "pretty" error message', () => { |
| 3 | + const [ |
| 4 | + { |
| 5 | + pattern: [{regexp}] |
| 6 | + } |
| 7 | + ] = require('../.github/tsc.json').problemMatcher; |
| 8 | + const exampleErrorMessage = |
| 9 | + "lib/index.js:23:42 - error TS2345: Argument of type 'A' is not assignable to parameter of type 'B'."; |
| 10 | + |
| 11 | + const match = exampleErrorMessage.match(new RegExp(regexp)); |
| 12 | + expect(match).not.toBeNull(); |
| 13 | + expect(match![1]).toEqual('lib/index.js'); |
| 14 | + expect(match![2]).toEqual('23'); |
| 15 | + expect(match![3]).toEqual('42'); |
| 16 | + expect(match![4]).toEqual('error'); |
| 17 | + expect(match![5]).toEqual('2345'); |
| 18 | + expect(match![6]).toEqual( |
| 19 | + "Argument of type 'A' is not assignable to parameter of type 'B'." |
| 20 | + ); |
| 21 | + }); |
| 22 | + |
| 23 | + it('tsc: matches TypeScript error message from log file', () => { |
| 24 | + const [ |
| 25 | + { |
| 26 | + pattern: [{regexp}] |
| 27 | + } |
| 28 | + ] = require('../.github/tsc.json').problemMatcher; |
| 29 | + const exampleErrorMessage = |
| 30 | + "lib/index.js(23,42): error TS2345: Argument of type 'A' is not assignable to parameter of type 'B'."; |
| 31 | + |
| 32 | + const match = exampleErrorMessage.match(new RegExp(regexp)); |
| 33 | + expect(match).not.toBeNull(); |
| 34 | + expect(match![1]).toEqual('lib/index.js'); |
| 35 | + expect(match![2]).toEqual('23'); |
| 36 | + expect(match![3]).toEqual('42'); |
| 37 | + expect(match![4]).toEqual('error'); |
| 38 | + expect(match![5]).toEqual('2345'); |
| 39 | + expect(match![6]).toEqual( |
| 40 | + "Argument of type 'A' is not assignable to parameter of type 'B'." |
| 41 | + ); |
| 42 | + }); |
| 43 | +}); |
0 commit comments