testPackagesArePinnedByCompatibleRange

tcmts.core.test.hash.testPackagesArePinnedByCompatibleRange · #iyuyonxo · term

Packages are pinned by compatible range, and the exact version checked against is reported.

import { analyzeTsx, dir, fakeReact } from "#codebase/tcmts/core/test/hash";
import assert from "node:assert/strict";

export const testPackagesArePinnedByCompatibleRange = () => {
  fakeReact(dir);
  const a = analyzeTsx(`import { useState } from "react";\nexport const s = useState;`);
  assert.equal(a.defs[0]!.deps.find((d) => d.ref.startsWith("npm:"))?.ref, "npm:react@19#useState");
  assert.deepEqual(a.packages, { "npm:react@19": "19.0.0" }, "for the codebase's lock");
}

uses