Skip to content

Generate tests in dtslint with Vanilla#1284

Draft
JanKrivanek wants to merge 1 commit intomicrosoft:mainfrom
JanKrivanek:dev/jankrivanek/testgen-dtslint-vanilla
Draft

Generate tests in dtslint with Vanilla#1284
JanKrivanek wants to merge 1 commit intomicrosoft:mainfrom
JanKrivanek:dev/jankrivanek/testgen-dtslint-vanilla

Conversation

@JanKrivanek
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

I made some specific comments. Overall the tests that were written were good, but there's a strong preference for testing pure functions, even where the value is low. Nearly all pure functions get tests, a few simple side-effecting functions get tests, and no complex side-effecting functions get tests.

}

function normalizePath(file: string) {
/** @internal */
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@internal doesn't actually mean anything in Typescript. It's a tag used by the typescript team to build the typescript compiler but nowhere else. It doesn't mean anything more than "please don't use this" here, which I guess is O.K., but still a little misleading.

});

describe("checkTsconfig - lib", () => {
it("errors when lib is missing", () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think a human might also over-divide the describe sections, but the AI definitely should have put all the checkTsconfig it assertions into one section.

});

describe("checkTsconfig - types with entries", () => {
it("errors when types array has entries", () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should also check missing case and empty case (I think they're both success cases, so maybe they're checked elsewhere?)

expect(checkTsconfig(based({ noUncheckedIndexedAccess: true }))).toEqual([]);
});
});
});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

no tests for arethetypeswrong running or the function that matches @types/X -> X and retrieves X from npm. these are the hard ones since they require mocking a bunch of stuff.

import path from "path";
import os from "os";

describe("createProgram", () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

these tests are pretty good

});
});

describe("combineErrorsAndWarnings", () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

these tests are nice but extremely low-value. If this were part of a human PR adding some feature, I'd tell them not to bother. Since the task for the AI presumably was "fill in missing test coverage", it kind of makes sense here.

});
});

describe("checkExpectedFiles", () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

these tests are good; I remember having a couple of bugs in this function that didn't turn up in the initial full run on DT, but were found by humans later.


const result = checkExpectedFiles(versionDir, true);
expect(result.errors).toContainEqual(expect.stringContaining("should contain /v16/"));
});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

doesn't check that tslint.json is banned

expect(result.errors).toContainEqual(expect.stringContaining("should contain /v16/"));
});
});
});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the difficult functions from index, testTypesVersion and runTests, are not tested. It's not too bad because mostly they call out to other functions, but runTests does have some complex checks that would be good to verify.

import { testNoLintDisables, normalizePath, isTypesVersionPath, startsWithDirectory, range } from "../src/lint";
import { TypeScriptVersion } from "@definitelytyped/typescript-versions";

describe("lint", () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

good organisation but no tests for getSourceFiles or anything else that touches eslint. just the pure functions.

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.

2 participants