Skip to content

Commit

Permalink
Merge pull request #1 from lumaxis/feature/add-tsc-problem-matcher-tests
Browse files Browse the repository at this point in the history
Add tests for tsc problem matcher
  • Loading branch information
Zarel authored Feb 17, 2021
2 parents c7026a4 + 7a808f9 commit 5f44226
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
5 changes: 0 additions & 5 deletions __tests__/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@ import path from 'path';
import * as main from '../src/main';
import * as im from '../src/installer';
import * as auth from '../src/authutil';
import {context} from '@actions/github';

let nodeTestManifest = require('./data/versions-manifest.json');
let nodeTestDist = require('./data/node-dist-index.json');

// let matchers = require('../matchers.json');
// let matcherPattern = matchers.problemMatcher[0].pattern[0];
// let matcherRegExp = new RegExp(matcherPattern.regexp);

describe('setup-node', () => {
let inputs = {} as any;
let os = {} as any;
Expand Down
43 changes: 43 additions & 0 deletions __tests__/problem-matcher.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
describe('problem matcher tests', () => {
it('tsc: matches TypeScript "pretty" error message', () => {
const [
{
pattern: [{regexp}]
}
] = require('../.github/tsc.json').problemMatcher;
const exampleErrorMessage =
"lib/index.js:23:42 - error TS2345: Argument of type 'A' is not assignable to parameter of type 'B'.";

const match = exampleErrorMessage.match(new RegExp(regexp));
expect(match).not.toBeNull();
expect(match![1]).toEqual('lib/index.js');
expect(match![2]).toEqual('23');
expect(match![3]).toEqual('42');
expect(match![4]).toEqual('error');
expect(match![5]).toEqual('2345');
expect(match![6]).toEqual(
"Argument of type 'A' is not assignable to parameter of type 'B'."
);
});

it('tsc: matches TypeScript error message from log file', () => {
const [
{
pattern: [{regexp}]
}
] = require('../.github/tsc.json').problemMatcher;
const exampleErrorMessage =
"lib/index.js(23,42): error TS2345: Argument of type 'A' is not assignable to parameter of type 'B'.";

const match = exampleErrorMessage.match(new RegExp(regexp));
expect(match).not.toBeNull();
expect(match![1]).toEqual('lib/index.js');
expect(match![2]).toEqual('23');
expect(match![3]).toEqual('42');
expect(match![4]).toEqual('error');
expect(match![5]).toEqual('2345');
expect(match![6]).toEqual(
"Argument of type 'A' is not assignable to parameter of type 'B'."
);
});
});

0 comments on commit 5f44226

Please sign in to comment.