Skip to content

Commit 999c504

Browse files
committed
fix: fail snap tests when a case directory is missing steps.json
Instead of warning and skipping, directories without steps.json now cause a hard error so CI won't silently drop test cases.
1 parent 5490e09 commit 999c504

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

packages/tools/src/snap-test.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,30 @@ export async function snapTest() {
126126
const casesDir = path.resolve(values.dir || 'snap-tests');
127127

128128
const taskFunctions: (() => Promise<void>)[] = [];
129+
const missingStepsJson: string[] = [];
129130
for (const caseName of fs.readdirSync(casesDir)) {
130131
if (caseName.startsWith('.')) {
131132
continue;
132-
} // Skip hidden files like .DS_Store
133-
if (!fs.existsSync(path.join(casesDir, caseName, 'steps.json'))) {
134-
console.warn('Warning: %s has no steps.json, skipping', caseName);
133+
}
134+
const caseDir = path.join(casesDir, caseName);
135+
if (!fs.statSync(caseDir).isDirectory()) {
136+
continue;
137+
}
138+
if (!fs.existsSync(path.join(caseDir, 'steps.json'))) {
139+
missingStepsJson.push(caseName);
135140
continue;
136141
}
137142
if (caseName.includes(filter)) {
138143
taskFunctions.push(() => runTestCase(caseName, tempTmpDir, casesDir, values['bin-dir']));
139144
}
140145
}
141146

147+
if (missingStepsJson.length > 0) {
148+
throw new Error(
149+
`${missingStepsJson.length} test case(s) missing steps.json: ${missingStepsJson.join(', ')}`,
150+
);
151+
}
152+
142153
if (taskFunctions.length > 0) {
143154
const cpuCount = cpus().length;
144155
console.log(

0 commit comments

Comments
 (0)