Skip to content

Commit d177419

Browse files
committed
test: ensure snapshot files are copied to build directory
1 parent d082ca4 commit d177419

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

scripts/post-build.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,42 @@ export const ExperimentName = {
9494
writeFile(runtimeFile, runtimeContent);
9595

9696
copyDevToolsDescriptionFiles();
97+
copySnapshotFiles();
98+
}
99+
100+
function copySnapshotFiles() {
101+
const testsDir = path.join(process.cwd(), 'tests');
102+
const buildTestsDir = path.join(BUILD_DIR, 'tests');
103+
104+
if (!fs.existsSync(buildTestsDir)) {
105+
fs.mkdirSync(buildTestsDir, {recursive: true});
106+
}
107+
108+
const files = fs.readdirSync(testsDir);
109+
for (const file of files) {
110+
if (file.endsWith('.snapshot')) {
111+
fs.copyFileSync(path.join(testsDir, file), path.join(buildTestsDir, file));
112+
}
113+
}
114+
115+
// Also handle subdirectories if needed, but for now we only have snapshots in the root of tests/
116+
// Wait, let's check tools/
117+
const toolsTestsDir = path.join(testsDir, 'tools');
118+
const buildToolsTestsDir = path.join(buildTestsDir, 'tools');
119+
if (fs.existsSync(toolsTestsDir)) {
120+
if (!fs.existsSync(buildToolsTestsDir)) {
121+
fs.mkdirSync(buildToolsTestsDir, {recursive: true});
122+
}
123+
const toolsFiles = fs.readdirSync(toolsTestsDir);
124+
for (const file of toolsFiles) {
125+
if (file.endsWith('.snapshot')) {
126+
fs.copyFileSync(
127+
path.join(toolsTestsDir, file),
128+
path.join(buildToolsTestsDir, file),
129+
);
130+
}
131+
}
132+
}
97133
}
98134

99135
function copyDevToolsDescriptionFiles() {

0 commit comments

Comments
 (0)