The fixtures should reflect the parsing logic and edge cases should be implemented visibly as over write.
Before:
exportfunctionconfig(outputDir='tmp'): CoreConfig{return{persist: { outputDir },// ...}};it('should throw if outputDir is invalid',()=>{constpersistConfigMock=persistConfig({outputDir : ' '});expect(()=>persistConfigSchema.parse(persistConfigMock)).toThrow(`path is invalid`,);});This is not in sync with the logic like default, validation etc in schemas. A change later already fail in the mock and we have to use visible overwrites for invalid data.
After:
exportfunctionconfig(outputDir='tmp'): CoreConfig{return{persist: persistConfigSchema.parse({ outputDir }),// ...}};it('should throw if outputDir is invalid',()=>{constpersistConfigMock=persistConfig();persistConfigMock.outputDir=' ';expect(()=>persistConfigSchema.parse(persistConfigMock)).toThrow(`path is invalid`,);});
The fixtures should reflect the parsing logic and edge cases should be implemented visibly as over write.
Before:
This is not in sync with the logic like default, validation etc in schemas. A change later already fail in the mock and we have to use visible overwrites for invalid data.
After: