MCPcopy
hub / github.com/affaan-m/ECC / runTests

Function runTests

tests/scripts/preview-pack-smoke.test.js:133–256  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

131}
132
133function runTests() {
134 console.log('\n=== Testing preview-pack-smoke.js ===\n');
135
136 let passed = 0;
137 let failed = 0;
138
139 if (test('parseArgs accepts smoke flags and rejects invalid values', () => {
140 const rootDir = createTempDir('preview-pack-smoke-args-');
141
142 try {
143 const parsed = parseArgs([
144 'node',
145 'script',
146 '--format=json',
147 `--root=${rootDir}`,
148 ]);
149
150 assert.strictEqual(parsed.format, 'json');
151 assert.strictEqual(parsed.root, path.resolve(rootDir));
152 assert.throws(() => parseArgs(['node', 'script', '--format', 'xml']), /Invalid format/);
153 assert.throws(() => parseArgs(['node', 'script', '--root']), /--root requires a value/);
154 assert.throws(() => parseArgs(['node', 'script', '--unknown']), /Unknown argument/);
155 } finally {
156 cleanup(rootDir);
157 }
158 })) passed++; else failed++;
159
160 if (test('seeded release pack passes every smoke check', () => {
161 const rootDir = createTempDir('preview-pack-smoke-pass-');
162
163 try {
164 seedRepo(rootDir);
165 const report = buildReport({ root: rootDir });
166
167 assert.strictEqual(report.schema_version, 'ecc.preview-pack-smoke.v1');
168 assert.strictEqual(report.ready, true);
169 assert.strictEqual(report.summary.failed, 0);
170 assert.ok(report.checks.every(check => check.status === 'pass'));
171
172 const text = renderText(report);
173 assert.ok(text.includes('Ready: yes'));
174 assert.ok(text.includes('Passed: 5'));
175 assert.ok(text.includes('Failed: 0'));
176 } finally {
177 cleanup(rootDir);
178 }
179 })) passed++; else failed++;
180
181 if (test('script registration fails closed without package wiring', () => {
182 const rootDir = createTempDir('preview-pack-smoke-package-');
183
184 try {
185 seedRepo(rootDir, {
186 'package.json': JSON.stringify({ files: [], scripts: {} }, null, 2),
187 });
188
189 const report = buildReport({ root: rootDir });
190 const registration = report.checks.find(check => check.id === 'preview-pack-script-registered');

Callers 1

Calls 11

okMethod · 0.80
testFunction · 0.70
createTempDirFunction · 0.70
cleanupFunction · 0.70
seedRepoFunction · 0.70
runFunction · 0.70
writeFileFunction · 0.70
runProcessFunction · 0.70
parseArgsFunction · 0.50
buildReportFunction · 0.50
renderTextFunction · 0.50

Tested by

no test coverage detected