Skip to content

Commit

Permalink
feat(formatter): expose to public API
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy-mitchell committed Mar 11, 2023
1 parent b777588 commit 359ee6a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions source/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import tsd from './lib';
import formatter from './lib/formatter';

export * from './lib/assertions/assert';
export {formatter};
export default tsd;
16 changes: 16 additions & 0 deletions source/test/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import path from 'path';
import test from 'ava';
import execa from 'execa';
import readPkgUp from 'read-pkg-up';
import tsd, {formatter} from '..';

interface ExecaError extends Error {
readonly exitCode: number;
Expand Down Expand Up @@ -95,3 +96,18 @@ test('cli typings and files flags', async t => {
t.is(exitCode, 1);
t.true(stderr.includes('✖ 5:19 Argument of type number is not assignable to parameter of type string.'));
});

test('exported formatter matches tsd results', async t => {
const options = {
cwd: path.join(__dirname, 'fixtures/failure'),
};

const {stderr: cliResults} = await t.throwsAsync<ExecaError>(execa('../../../cli.js', options));

t.true(cliResults.includes('✖ 5:19 Argument of type number is not assignable to parameter of type string.'));

const tsdResults = await tsd(options);
const formattedResults = formatter(tsdResults);

t.true(formattedResults.includes('✖ 5:19 Argument of type number is not assignable to parameter of type string.'));
});

0 comments on commit 359ee6a

Please sign in to comment.