diff --git a/src/random.ts b/src/random.ts index a653472f7f8..448cf4f8696 100644 --- a/src/random.ts +++ b/src/random.ts @@ -326,7 +326,7 @@ export class Random { const randomWordMethod = this.faker.random.arrayElement(wordMethods); result = randomWordMethod(); - } while (bannedChars.some((char) => result.includes(char))); + } while (!result || bannedChars.some((char) => result.includes(char))); return this.faker.random.arrayElement(result.split(' ')); } diff --git a/test/system.spec.ts b/test/system.spec.ts index de7d0390dff..26b5730fbdb 100644 --- a/test/system.spec.ts +++ b/test/system.spec.ts @@ -268,4 +268,19 @@ describe('system', () => { }); } }); + + describe('extra tests', () => { + describe('commonFileName()', () => { + afterEach(() => { + faker.locale = 'en'; + }); + + it('#770', () => { + faker.seed(5423027051750305); + faker.setLocale('sk'); + faker.system.commonFileName('xml'); + faker.system.commonFileName('xml'); + }); + }); + }); });