Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"LICENSE"
],
"scripts": {
"test": "node --test test/*.test.mjs",
"test": "node scripts/run-node-test-files.mjs",
"pack:dry-run": "npm pack --dry-run"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion plugins/omo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
"check": "npm run build && npm test",
"sync:hooks": "node scripts/sync-hook-status-messages.mjs",
"sync:skills": "node scripts/sync-skills.mjs",
"test": "node --test test/*.test.mjs"
"test": "node ../../scripts/run-node-test-files.mjs"
}
}
25 changes: 20 additions & 5 deletions plugins/omo/test/aggregate-build.test.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import { readFile, stat } from "node:fs/promises";
import { join } from "node:path";
import test from "node:test";

import { readJson, root } from "./aggregate-plugin-fixture.mjs";
import { readJson, repoRoot, root } from "./aggregate-plugin-fixture.mjs";

async function pathExists(path) {
try {
await stat(path);
return true;
} catch (error) {
if (error instanceof Error && "code" in error && error.code === "ENOENT") return false;
throw error;
}
}

test("#given aggregate plugin build script #when inspected #then generated assets run before workspace builds", async () => {
// given
Expand All @@ -21,14 +31,19 @@ test("#given aggregate plugin build script #when inspected #then generated asset
);
assert.match(buildScript, /^node scripts\/sync-version\.mjs &&/);
assert.match(buildScript, /materialize-shared-upstreams\.mjs --strict && node scripts\/sync-skills\.mjs/);
assert.equal(testScript, "node --test test/*.test.mjs");
assert.equal(testScript, "node ../../scripts/run-node-test-files.mjs");
assert(packageJson.workspaces.includes("components/ultrawork"));
assert.doesNotMatch(packageText, /\bpython3?\b|ultrawork-detector\.py/);
});

test("#given omo-codex package build script #when inspected #then delegates to the aggregate plugin package", async () => {
test("#given omo-codex package build script #when inspected #then delegates to the aggregate plugin package", async (t) => {
// given
const packageJson = JSON.parse(await readFile(join(root, "..", "package.json"), "utf8"));
const packageJsonPath = join(repoRoot, "packages", "omo-codex", "package.json");
if (!(await pathExists(packageJsonPath))) {
t.skip("LazyCodex mirror does not include the omo-codex wrapper package");
return;
}
const packageJson = JSON.parse(await readFile(packageJsonPath, "utf8"));

// when
const buildPluginScript = packageJson.scripts["build:plugin"];
Expand Down
14 changes: 14 additions & 0 deletions scripts/run-node-test-files.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { spawnSync } from "node:child_process"
import { readdirSync } from "node:fs"
import { join } from "node:path"

const testFiles = readdirSync("test")
.filter((file) => file.endsWith(".test.mjs"))
.sort()
.map((file) => join("test", file))

const result = spawnSync(process.execPath, ["--test", ...testFiles], {
stdio: "inherit",
})

process.exit(result.status ?? 1)
6 changes: 4 additions & 2 deletions test/lazycodex-ai-bin.test.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import assert from "node:assert/strict"
import { existsSync, readFileSync } from "node:fs"
import { join } from "node:path"
import { dirname, join } from "node:path"
import { spawnSync } from "node:child_process"
import { describe, it } from "node:test"
import { fileURLToPath } from "node:url"

const root = new URL("..", import.meta.url).pathname
const root = dirname(dirname(fileURLToPath(import.meta.url)))
const packageJsonPath = join(root, "package.json")
const packageLockPath = join(root, "package-lock.json")
const publishWorkflowPath = join(root, ".github", "workflows", "npm-publish.yml")
Expand All @@ -23,6 +24,7 @@ describe("lazycodex-ai npm package", () => {
assert.equal(manifest.name, "lazycodex-ai")
assert.equal(manifest.version, releaseVersion)
assert.equal(manifest.bin?.["lazycodex-ai"], "bin/lazycodex-ai.js")
assert.equal(manifest.scripts?.test, "node scripts/run-node-test-files.mjs")
assert.equal(manifest.private, undefined)
})

Expand Down