From cdcc663ba9cbdc49af2447e36ef67eff04bc1e56 Mon Sep 17 00:00:00 2001 From: Okiki Ojo Date: Wed, 11 Feb 2026 20:56:17 -0500 Subject: [PATCH] chore(tests): remove unused imports and improve test clarity Signed-off-by: Okiki Ojo --- core/tests/01-conditional-exports.test.ts | 9 ++------- core/tests/03-legacy-fields.test.ts | 9 ++++----- core/tests/04-browser-remapping.test.ts | 4 ---- core/tests/05-platform-remapping.test.ts | 10 +++++----- core/tests/06-relative-imports.test.ts | 3 --- core/tests/07-tree-shaking.test.ts | 5 ----- core/tests/08-non-npm-resolution.test.ts | 2 -- core/tests/09-builtins-polyfills.test.ts | 2 -- core/tests/10-dual-package.test.ts | 3 --- core/tests/11-edge-cases.test.ts | 3 --- core/tests/12-runtime-conditions.test.ts | 3 --- core/tests/helpers.ts | 4 ++-- 12 files changed, 13 insertions(+), 44 deletions(-) diff --git a/core/tests/01-conditional-exports.test.ts b/core/tests/01-conditional-exports.test.ts index 1302dd6..44b939f 100644 --- a/core/tests/01-conditional-exports.test.ts +++ b/core/tests/01-conditional-exports.test.ts @@ -13,16 +13,11 @@ import { expect } from "@std/expect"; import { resolveModern, - resolvePackageEntry, getResolverConditions, - getLegacyMainFields, manifest, importArgs, resolveOpts, buildPackage, - getOutputText, - NETWORK_TIMEOUT, - UNIT_TIMEOUT, } from "./helpers.ts"; // ============================================================================= @@ -224,7 +219,7 @@ describe("01 · Conditional Exports", () => { describe("1.5 — Single-string exports (chalk-like)", () => { const pkg = manifest({ type: "module", - exports: "./source/index.js" as any, + exports: "./source/index.js", }); test("resolves the string directly", () => { @@ -270,7 +265,7 @@ describe("01 · Conditional Exports", () => { const pkg = manifest({ exports: { ".": "./index.js", - "./internal": null as any, + "./internal": null, }, }); diff --git a/core/tests/03-legacy-fields.test.ts b/core/tests/03-legacy-fields.test.ts index e69e1d3..ef82cb1 100644 --- a/core/tests/03-legacy-fields.test.ts +++ b/core/tests/03-legacy-fields.test.ts @@ -20,7 +20,6 @@ import { importArgs, resolveOpts, buildPackage, - NETWORK_TIMEOUT, } from "./helpers.ts"; // ============================================================================= @@ -36,7 +35,7 @@ describe("03 · Legacy Field Resolution", () => { const result = resolveLegacy(pkg, { browser: true }, fields); expect(result.excluded).toBe(false); - expect(result.entryPoint).toBe("index.js"); + expect(result.entryPoint).toBe("./index.js"); }); test("node build resolves to main", () => { @@ -44,7 +43,7 @@ describe("03 · Legacy Field Resolution", () => { const result = resolveLegacy(pkg, { browser: false }, fields); expect(result.excluded).toBe(false); - expect(result.entryPoint).toBe("index.js"); + expect(result.entryPoint).toBe("./index.js"); }); }); @@ -62,7 +61,7 @@ describe("03 · Legacy Field Resolution", () => { // No browser field → falls to module expect(result.excluded).toBe(false); - expect(result.entryPoint).toBe("lodash.js"); + expect(result.entryPoint).toBe("./lodash.js"); }); }); @@ -125,7 +124,7 @@ describe("03 · Legacy Field Resolution", () => { const pkg = manifest({ main: "./moment.js", "jsnext:main": "./dist/moment.js", - } as any); + }); test("resolveLegacy ignores jsnext:main, picks main", () => { const fields = ["module", "main"]; diff --git a/core/tests/04-browser-remapping.test.ts b/core/tests/04-browser-remapping.test.ts index af9fce9..50ee1b8 100644 --- a/core/tests/04-browser-remapping.test.ts +++ b/core/tests/04-browser-remapping.test.ts @@ -17,15 +17,11 @@ import { resolveLegacy, applyPathRemapping, applyManifestRemappings, - resolvePackageEntry, getResolverConditions, - getLegacyMainFields, manifest, importArgs, resolveOpts, buildPackage, - getOutputText, - NETWORK_TIMEOUT, } from "./helpers.ts"; // ============================================================================= diff --git a/core/tests/05-platform-remapping.test.ts b/core/tests/05-platform-remapping.test.ts index 459787f..8fd220b 100644 --- a/core/tests/05-platform-remapping.test.ts +++ b/core/tests/05-platform-remapping.test.ts @@ -40,7 +40,7 @@ describe("05 · Platform-Specific Remapping", () => { "./fallback/platform.js": "./fallback/platform.native.js", "./fallback/utf8.auto.js": "./fallback/utf8.auto.native.js", }, - } as any); + }); test("react-native runtime → remaps to .native.js", () => { const conds = getResolverConditions( @@ -66,7 +66,7 @@ describe("05 · Platform-Specific Remapping", () => { const pkg = manifest({ browser: { "./lib/impl.js": "./lib/impl.browser.js" }, "react-native": { "./lib/impl.js": "./lib/impl.native.js" }, - } as any); + }); test("react-native wins over browser", () => { // Simulate both conditions being active @@ -85,7 +85,7 @@ describe("05 · Platform-Specific Remapping", () => { const pkg = manifest({ browser: { "./lib/crypto.js": "./lib/crypto.browser.js" }, electron: { "./lib/crypto.js": "./lib/crypto.electron.js" }, - } as any); + }); test("electron-renderer: electron field wins over browser", () => { const conds = getResolverConditions( @@ -122,7 +122,7 @@ describe("05 · Platform-Specific Remapping", () => { const pkg = manifest({ browser: { "./fallback/platform.js": "./fallback/platform.browser.js" }, "react-native": { "./fallback/platform.js": "./fallback/platform.native.js" }, - } as any); + }); test("deno runtime: no condition matches → pass-through", () => { const conds = getResolverConditions( @@ -142,7 +142,7 @@ describe("05 · Platform-Specific Remapping", () => { "./lib/dom-impl.js": false, "./lib/platform.js": "./lib/platform.native.js", }, - } as any); + }); test("react-native build: false excludes the module", () => { const conds = getResolverConditions( diff --git a/core/tests/06-relative-imports.test.ts b/core/tests/06-relative-imports.test.ts index 5a662c8..7053c75 100644 --- a/core/tests/06-relative-imports.test.ts +++ b/core/tests/06-relative-imports.test.ts @@ -13,9 +13,6 @@ import { expect } from "@std/expect"; import { buildPackage, - buildWithEntry, - getOutputText, - NETWORK_TIMEOUT, } from "./helpers.ts"; // ============================================================================= diff --git a/core/tests/07-tree-shaking.test.ts b/core/tests/07-tree-shaking.test.ts index 2249f20..2751897 100644 --- a/core/tests/07-tree-shaking.test.ts +++ b/core/tests/07-tree-shaking.test.ts @@ -13,16 +13,11 @@ import { expect } from "@std/expect"; import { computeEsbuildSideEffects, - compileSideEffectsMatchers, - normalizeSideEffectsPattern, normalizePkgRelPath, isJsLikePath, manifest, buildPackage, buildWithEntry, - getOutputText, - NETWORK_TIMEOUT, - UNIT_TIMEOUT, } from "./helpers.ts"; // ============================================================================= diff --git a/core/tests/08-non-npm-resolution.test.ts b/core/tests/08-non-npm-resolution.test.ts index 650487b..602b390 100644 --- a/core/tests/08-non-npm-resolution.test.ts +++ b/core/tests/08-non-npm-resolution.test.ts @@ -14,8 +14,6 @@ import { expect } from "@std/expect"; import { buildPackage, buildWithEntry, - getOutputText, - NETWORK_TIMEOUT, } from "./helpers.ts"; // ============================================================================= diff --git a/core/tests/09-builtins-polyfills.test.ts b/core/tests/09-builtins-polyfills.test.ts index 0777879..494a9a6 100644 --- a/core/tests/09-builtins-polyfills.test.ts +++ b/core/tests/09-builtins-polyfills.test.ts @@ -14,11 +14,9 @@ import { expect } from "@std/expect"; import { buildPackage, - buildWithEntry, getOutputText, outputContains, outputMatches, - NETWORK_TIMEOUT, } from "./helpers.ts"; // ============================================================================= diff --git a/core/tests/10-dual-package.test.ts b/core/tests/10-dual-package.test.ts index 1d5036e..4770b6b 100644 --- a/core/tests/10-dual-package.test.ts +++ b/core/tests/10-dual-package.test.ts @@ -20,12 +20,9 @@ import { importArgs, resolveOpts, buildPackage, - buildWithEntry, getOutputText, outputContains, outputMatches, - NETWORK_TIMEOUT, - UNIT_TIMEOUT, } from "./helpers.ts"; // ============================================================================= diff --git a/core/tests/11-edge-cases.test.ts b/core/tests/11-edge-cases.test.ts index f994d41..65a6383 100644 --- a/core/tests/11-edge-cases.test.ts +++ b/core/tests/11-edge-cases.test.ts @@ -14,7 +14,6 @@ import { expect } from "@std/expect"; import { resolveModern, getResolverConditions, - computePeerDependencies, manifest, importArgs, resolveOpts, @@ -22,8 +21,6 @@ import { buildWithEntry, getOutputText, outputContains, - NETWORK_TIMEOUT, - UNIT_TIMEOUT, } from "./helpers.ts"; // ============================================================================= diff --git a/core/tests/12-runtime-conditions.test.ts b/core/tests/12-runtime-conditions.test.ts index 08166c5..dd313b7 100644 --- a/core/tests/12-runtime-conditions.test.ts +++ b/core/tests/12-runtime-conditions.test.ts @@ -22,9 +22,6 @@ import { importArgs, resolveOpts, buildPackage, - getOutputText, - NETWORK_TIMEOUT, - UNIT_TIMEOUT, } from "./helpers.ts"; import type { ResolveRuntime } from "./helpers.ts"; diff --git a/core/tests/helpers.ts b/core/tests/helpers.ts index 7272a31..8b83d20 100644 --- a/core/tests/helpers.ts +++ b/core/tests/helpers.ts @@ -14,7 +14,7 @@ import type { PackageJson } from "@bundle/utils/types"; import type { ResolverConditionInputs } from "@bundle/utils/resolve-conditions"; import { build, TheFileSystem } from "../build.ts"; -import { getFile, setFile } from "../utils/filesystem.ts"; +import { setFile } from "../utils/filesystem.ts"; // Re-export resolution functions for unit testing export { @@ -121,7 +121,7 @@ export async function buildWithEntry( * * Generates `export * from "";` as the entry code. */ -export async function buildPackage( +export function buildPackage( specifier: string, config: BuildConfig = {}, ): Promise { -- 2.51.2