Skip to content

Commit

Permalink
fix: dont log deprecations on startup (#857)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 committed Apr 21, 2022
1 parent fe8eea4 commit a28b5de
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/unique.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
21 changes: 20 additions & 1 deletion test/faker.spec.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit a28b5de

Please sign in to comment.