Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove internal paths from test dependencies #104

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/definitions-parser/src/lib/module-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,8 @@ export function getTestDependencies(
for (const { fileName: ref } of referencedFiles) {
throw new Error(`Test files should not use '<reference path="" />'. '${filePath()}' references '${ref}'.`);
}
for (const { fileName: referencedPackage } of typeReferenceDirectives) {
for (const { fileName: ref } of typeReferenceDirectives) {
const referencedPackage = rootName(ref, typeFiles, packageName);
if (dependencies.has(referencedPackage)) {
throw new Error(
`'${filePath()}' unnecessarily references '${referencedPackage}', which is already referenced in the type definition.`
Expand Down
13 changes: 13 additions & 0 deletions packages/definitions-parser/test/module-info.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,18 @@ testo({
const i = getModuleInfo("boring", types);
const d = getTestDependencies("boring", types, tests.keys(), i.dependencies, fs.subDir("types").subDir("boring"));
expect(d).toEqual(new Set(["super-big-fun-hus"]));
},
getTestDependenciesRemovesInternalPaths() {
const pkg = new Dir(undefined);
pkg.set(
"mock-tests.ts",
`/// <reference types="test-dependency/component" />
`
);
const memFS = new InMemoryFS(pkg, "types/mock");
const { types, tests } = allReferencedFiles(["mock-tests.ts"], memFS, "mock", "types/mock");
const { dependencies } = getModuleInfo("mock", types);
const testDependencies = getTestDependencies("mock", types, tests.keys(), dependencies, memFS);
expect(Array.from(testDependencies)).toEqual(["test-dependency"]);
}
});