Skip to content

Commit a28b5de

Browse files
authored
fix: dont log deprecations on startup (#857)
1 parent fe8eea4 commit a28b5de

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

src/unique.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,12 @@ export class Unique {
8383
constructor() {
8484
// Bind `this` so namespaced is working correctly
8585
for (const name of Object.getOwnPropertyNames(Unique.prototype)) {
86-
if (name === 'constructor' || typeof this[name] !== 'function') {
86+
if (
87+
name === 'constructor' ||
88+
name === 'maxTime' ||
89+
name === 'maxRetries' ||
90+
typeof this[name] !== 'function'
91+
) {
8792
continue;
8893
}
8994
this[name] = this[name].bind(this);

test/faker.spec.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { beforeEach, describe, expect, it } from 'vitest';
1+
import type { SpyInstance } from 'vitest';
2+
import { beforeEach, describe, expect, it, vi } from 'vitest';
23
import { faker, Faker } from '../src';
34
import { FakerError } from '../src/errors/faker-error';
45

@@ -31,6 +32,24 @@ describe('faker', () => {
3132
);
3233
});
3334

35+
it('should not log anything on startup', () => {
36+
const spies: Array<SpyInstance> = Object.keys(console)
37+
.filter((key) => typeof console[key] === 'function')
38+
.map((methodName) =>
39+
vi.spyOn(console, methodName as keyof typeof console)
40+
);
41+
42+
// eslint-disable-next-line @typescript-eslint/no-var-requires
43+
require('..').faker;
44+
45+
new Faker({ locales: { en: { title: '' } } });
46+
47+
for (const spy of spies) {
48+
expect(spy).not.toHaveBeenCalled();
49+
spy.mockRestore();
50+
}
51+
});
52+
3453
describe('definitions', () => {
3554
describe('title', () => {
3655
it.each(Object.keys(faker.locales))('title (%s)', (locale) => {

0 commit comments

Comments
 (0)