aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinigami <[email protected]>2022-04-21 20:33:59 +0200
committerGitHub <[email protected]>2022-04-21 18:33:59 +0000
commita28b5deab9079c567b7eb8a1917c661cadd35849 (patch)
tree2a5c67c09186272a85fdbbefc1a889f4877794c9
parentfe8eea46845959d9ad3e9d5f52eb2f35c14977c3 (diff)
downloadfaker-a28b5deab9079c567b7eb8a1917c661cadd35849.tar.xz
faker-a28b5deab9079c567b7eb8a1917c661cadd35849.zip
fix: dont log deprecations on startup (#857)
-rw-r--r--src/unique.ts7
-rw-r--r--test/faker.spec.ts21
2 files changed, 26 insertions, 2 deletions
diff --git a/src/unique.ts b/src/unique.ts
index ff8698e6..f59a8ef2 100644
--- a/src/unique.ts
+++ b/src/unique.ts
@@ -83,7 +83,12 @@ export class Unique {
constructor() {
// Bind `this` so namespaced is working correctly
for (const name of Object.getOwnPropertyNames(Unique.prototype)) {
- if (name === 'constructor' || typeof this[name] !== 'function') {
+ if (
+ name === 'constructor' ||
+ name === 'maxTime' ||
+ name === 'maxRetries' ||
+ typeof this[name] !== 'function'
+ ) {
continue;
}
this[name] = this[name].bind(this);
diff --git a/test/faker.spec.ts b/test/faker.spec.ts
index d8ca61c8..74171210 100644
--- a/test/faker.spec.ts
+++ b/test/faker.spec.ts
@@ -1,4 +1,5 @@
-import { beforeEach, describe, expect, it } from 'vitest';
+import type { SpyInstance } from 'vitest';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
import { faker, Faker } from '../src';
import { FakerError } from '../src/errors/faker-error';
@@ -31,6 +32,24 @@ describe('faker', () => {
);
});
+ it('should not log anything on startup', () => {
+ const spies: Array<SpyInstance> = Object.keys(console)
+ .filter((key) => typeof console[key] === 'function')
+ .map((methodName) =>
+ vi.spyOn(console, methodName as keyof typeof console)
+ );
+
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
+ require('..').faker;
+
+ new Faker({ locales: { en: { title: '' } } });
+
+ for (const spy of spies) {
+ expect(spy).not.toHaveBeenCalled();
+ spy.mockRestore();
+ }
+ });
+
describe('definitions', () => {
describe('title', () => {
it.each(Object.keys(faker.locales))('title (%s)', (locale) => {