Skip to content

Modernize test/bench runners#3038

Open
mfedderly wants to merge 9 commits intomasterfrom
mf/node-test-runner
Open

Modernize test/bench runners#3038
mfedderly wants to merge 9 commits intomasterfrom
mf/node-test-runner

Conversation

@mfedderly
Copy link
Collaborator

Some of the basics for modernizing our test runner to get away from tape.

  • Introduces support/testFixtures.mts and support/benchFixtures.mts to start to reuse code across packages. I know this won't work for every package, but it should work for most of them.
  • Migrate to built-ins instead of glob, load-json-file, tape, tsx, and write-json-file
  • Packages will have to migrate the test and bench methods at the same time

// point.geojson x 52,230,993 ops/sec ±0.70% (96 runs sampled)
// points-with-weights.geojson x 24,802,237 ops/sec ±0.33% (100 runs sampled)
// polygon-without-weights.geojson x 18,423,881 ops/sec ±0.28% (100 runs sampled)
// polygon.geojson x 24,990,920 ops/sec ±0.45% (99 runs sampled)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hilariously this is almost exactly 10x the original speed due to hardware progression over the years.

import type { BBox, Feature, GeoJsonProperties, Point } from "geojson";
import { bbox } from "@turf/bbox";
import { point, Id, AllGeoJSON } from "@turf/helpers";
import { point, type Id, type AllGeoJSON } from "@turf/helpers";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These type keywords are required when migrating from tsx to node native execution.

TAPE_PACKAGES.push(name);
} else {
NODE_TEST_PACKAGES.push(name);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Automatically differentiate if test.ts is tape or node native

scripts: {
bench: "node bench.ts",
"test:node": "node --test",
"test:tape": REMOVE,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Handles swapping bench from tsx execution to node as we switch to node native testing.

scripts: {
bench: "tsx bench.ts",
"test:tape": "tsx test.ts",
"test:node": REMOVE,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just in case we ever migrate from node native back to tape.

},
},
includePackages: NODE_TEST_PACKAGES,
}),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When we switch to node native testing and use the shared fixture runner, we get to remove a lot of dependencies in favor of the builtin tooling.

"@types/benchmark": "^2.1.5",
"@types/node": "22.15.3",
"acorn": "^8.14.1",
"benchmark": "^2.1.4",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is required because of shared/benchFixtures.mts, but we get to remove it from each package.

"skipLibCheck": true,
"erasableSyntaxOnly": true
"erasableSyntaxOnly": true,
"rewriteRelativeImportExtensions": true
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This seems to work just fine for us now. I had to do some extra stuff in geoclipper2 to have this all work with noEmit and a second tsconfig.json file for the production builds. I can revisit this situation if moving from tsup to raw tsc causes an issue.

@mfedderly mfedderly force-pushed the mf/node-test-runner branch from 7b73513 to b88c3d0 Compare March 13, 2026 00:00
Base automatically changed from mf/readme-generation to master March 16, 2026 15:03
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.

1 participant