diff --git a/src/fake.ts b/src/fake.ts index d56b4794741..4e92c9d5a46 100644 --- a/src/fake.ts +++ b/src/fake.ts @@ -116,6 +116,10 @@ export class Fake { // replace the found tag with the returned fake value res = str.replace('{{' + token + '}}', result); + if (res === '') { + return ''; + } + // return the response recursively until we are done finding all tags return this.fake(res); } diff --git a/test/fake.spec.ts b/test/fake.spec.ts index c8223585771..e91f9c8a882 100644 --- a/test/fake.spec.ts +++ b/test/fake.spec.ts @@ -46,5 +46,9 @@ describe('fake', () => { Error('Invalid method: address.foo') ); }); + + it('should be able to return empty strings', () => { + expect(faker.fake('{{helpers.repeatString}}')).toBe(''); + }); }); });