Skip to content

Verbose API results#75

Open
smartclash wants to merge 50 commits into
tsdjs:mainfrom
MLH-Fellowship:feature/verbose-reporting
Open

Verbose API results#75
smartclash wants to merge 50 commits into
tsdjs:mainfrom
MLH-Fellowship:feature/verbose-reporting

Conversation

@smartclash

@smartclash smartclash commented Aug 13, 2020

Copy link
Copy Markdown

This PR is dependent on #74

TSD either returns a null array if there is no test failures or an array of Diagnostic objects. This PR aims to make TSD return with ExtendedDiagnostic object no matter if the tests fail or not.

Merging this PR allows custom test runners like Jest to report the number of assertions it evaluated in each file.

It also means that it introduces a breaking change because TSD now returns...

  • An object with numTests and null diagnostics array if all tests passed.
{
    numTests: 1024, // Total number of tests it ran through
    diagnostics: [] // No failed test cases
}
  • An object with numTests and an diagnostics array populated with test fail reports if a test is failed.
{
    numTests: 1024, // Total number of tests it ran through
    diagnostics: [
        {
            fileName: 'add.test-d.ts',
            message: 'A message here',
            severity: 'error',
            line: 10,
            column: 34,
        },
        ...
    ]
}


This PR is Co-Authored By:

@Ethan-Arrowood Ethan-Arrowood left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks really good! nice work!

@sindresorhus sindresorhus changed the title Verbose reporting in TSD. Verbose API results Oct 3, 2020
@SimenB

SimenB commented Dec 16, 2020

Copy link
Copy Markdown

rebase this now that #74 has landed?

@SimenB

SimenB commented Oct 5, 2021

Copy link
Copy Markdown

Still very interested in seeing this land 😀

@tommy-mitchell tommy-mitchell mentioned this pull request Mar 6, 2023
@tommy-mitchell

tommy-mitchell commented Mar 13, 2023

Copy link
Copy Markdown
Contributor

Instead of making a breaking change, maybe tsd can just have verbose: boolean option?

const diagnostics = await tsd();
//=> Diagnostic[]

console.log(diagnostics.length);
//=> '0'
const verboseResults = await tsd({verbose: true});
//=> {testCount: number, diagnostics: Diagnostic[]}

console.log(verboseResults.testCount);
//=> '1024'

console.log(verboseResults.diagnostics.length);
//=> '0'

@sindresorhus

Copy link
Copy Markdown
Collaborator

I'm fine with this change. Having an object also gives us the opportunity to add additional properties in the future.

@sindresorhus

Copy link
Copy Markdown
Collaborator

Instead of making a breaking change, maybe tsd can just have verbose: boolean option?

I don't like options that change the return value type.

I think a breaking change is ok here. Programmatic use is not that common.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants