Skip to content

Commit c0815d8

Browse files
Stephen Millerclaude
authored andcommitted
feat: add test placeholder with node:test runner
Add test/ directory with a smoke test suite using Node.js built-in test runner (node:test). Tests verify package.json fields, CLI entry point, lib modules, and slash command files exist. Add "test" script to package.json so npm test works out of the box for contributors. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 83f4d76 commit c0815d8

2 files changed

Lines changed: 76 additions & 0 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"scripts": {
1515
"build": "pkgroll --clean-dist --src .",
1616
"dev": "pkgroll --watch --src .",
17+
"test": "node --test 'test/**/*.test.cjs'",
1718
"prepublishOnly": "npm run build"
1819
},
1920
"dependencies": {

test/mgw.test.cjs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* MGW — Placeholder test suite
3+
*
4+
* This file establishes the test directory and a minimal smoke test.
5+
* Future contributors should add tests here for:
6+
*
7+
* - CLI argument parsing (bin/mgw.cjs)
8+
* - State file read/write (lib/state.cjs)
9+
* - Template loading (lib/template-loader.cjs)
10+
* - Output formatting (lib/output.cjs)
11+
* - GitHub helpers (lib/github.cjs)
12+
*
13+
* Run with: npm test
14+
*
15+
* The test uses Node's built-in assert module and test runner (node:test)
16+
* which requires Node.js >= 18. No additional test dependencies needed.
17+
*/
18+
19+
const { describe, it } = require('node:test');
20+
const assert = require('node:assert/strict');
21+
const { existsSync } = require('node:fs');
22+
const { resolve } = require('node:path');
23+
24+
describe('mgw', () => {
25+
it('package.json exists and has required fields', () => {
26+
const pkgPath = resolve(__dirname, '..', 'package.json');
27+
assert.ok(existsSync(pkgPath), 'package.json should exist');
28+
29+
const pkg = require(pkgPath);
30+
assert.ok(pkg.name, 'package.json should have a name');
31+
assert.ok(pkg.version, 'package.json should have a version');
32+
assert.ok(pkg.bin, 'package.json should have a bin field');
33+
assert.ok(pkg.main, 'package.json should have a main field');
34+
});
35+
36+
it('CLI entry point exists', () => {
37+
const binPath = resolve(__dirname, '..', 'bin', 'mgw.cjs');
38+
assert.ok(existsSync(binPath), 'bin/mgw.cjs should exist');
39+
});
40+
41+
it('lib modules exist', () => {
42+
const libDir = resolve(__dirname, '..', 'lib');
43+
const expectedModules = [
44+
'index.cjs',
45+
'state.cjs',
46+
'github.cjs',
47+
'output.cjs',
48+
'gsd.cjs',
49+
'claude.cjs',
50+
'template-loader.cjs',
51+
'templates.cjs',
52+
];
53+
54+
for (const mod of expectedModules) {
55+
const modPath = resolve(libDir, mod);
56+
assert.ok(existsSync(modPath), `lib/${mod} should exist`);
57+
}
58+
});
59+
60+
it('commands directory has expected slash commands', () => {
61+
const cmdDir = resolve(__dirname, '..', 'commands');
62+
const expectedCommands = [
63+
'run.md',
64+
'issue.md',
65+
'init.md',
66+
'status.md',
67+
'sync.md',
68+
];
69+
70+
for (const cmd of expectedCommands) {
71+
const cmdPath = resolve(cmdDir, cmd);
72+
assert.ok(existsSync(cmdPath), `commands/${cmd} should exist`);
73+
}
74+
});
75+
});

0 commit comments

Comments
 (0)