Skip to content

Commit df9a788

Browse files
committed
Copy only if the snap base file does exist.
1 parent ce1845b commit df9a788

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎core-build/gulp-core-build/src/tasks/JestTask.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,20 @@ export class JestTask extends GulpTask<IJestConfig> {
152152
const pattern: string = path.join(srcRoot, '**/__snapshots__/*.snap');
153153
globby.sync(pattern).forEach(sourceFile => {
154154
const destination: string = sourceFile.replace(srcRoot, destRoot);
155-
fsx.copySync(sourceFile, destination);
155+
const tsDestination: string = destination.replace('.test.js.snap', '.test.ts.snap');
156+
const tsxDestination: string = destination.replace('.test.js.snap', '.test.tsx.snap');
157+
158+
if (this._doesSnapBaseFileExist(tsDestination)) {
159+
fsx.copySync(sourceFile, tsDestination);
160+
} else if (this._doesSnapBaseFileExist(tsxDestination)) {
161+
fsx.copySync(sourceFile, tsxDestination);
162+
}
156163
});
157164
}
165+
166+
private _doesSnapBaseFileExist(snapFilePath: string): boolean {
167+
const fileName: string = path.basename(snapFilePath, '.snap');
168+
const snapBaseFilePath: string = path.resolve(snapFilePath, '../../', fileName);
169+
return fsx.existsSync(snapBaseFilePath);
170+
}
158171
}

0 commit comments

Comments
 (0)