test(middleware-joi): hide `console.warn` logs
MODIFY
packages/middleware-joi/test/unit/body.spec.ts
packages/middleware-joi/test/unit/body.spec.ts
@@ -10,6 +10,10 @@ const MockReq = require('mock-req');
describe('Joi middleware - Body', () => {
const ctx = createMockEffectContext();
+ beforeEach(() => {
+ jest.spyOn(console, 'warn').mockImplementation(() => jest.fn());
+ });
+
it(`throws an error if doesn't pass a required field`, done => {
expect.assertions(2);

MODIFY
packages/middleware-joi/test/unit/header.spec.ts
packages/middleware-joi/test/unit/header.spec.ts
@@ -6,6 +6,10 @@ import { createHttpRequest } from '@marblejs/core/dist/+internal/testing';
import { validator$, Joi } from '../../src';
describe('Joi middleware - Header', () => {
+ beforeEach(() => {
+ jest.spyOn(console, 'warn').mockImplementation(() => jest.fn());
+ });
+
test('should throws an error if dont pass a required field', done => {
expect.assertions(2);

MODIFY
packages/middleware-joi/test/unit/params.spec.ts
packages/middleware-joi/test/unit/params.spec.ts
@@ -15,6 +15,10 @@ const reqMatched = (
} as any) as HttpRequest);
describe('Joi middleware - Params', () => {
+ beforeEach(() => {
+ jest.spyOn(console, 'warn').mockImplementation(() => jest.fn());
+ });
+
it('should throws an error if dont pass a required field', done => {
expect.assertions(2);
@@ -31,7 +35,6 @@ describe('Joi middleware - Params', () => {
http$.subscribe(
() => {
fail('Exceptions should be thrown');
- done();
},
error => {
expect(error).toBeDefined();
@@ -55,7 +58,6 @@ describe('Joi middleware - Params', () => {
http$.subscribe(
() => {
fail('Exceptions should be thrown');
- done();
},
error => {
expect(error).toBeDefined();

MODIFY
packages/middleware-joi/test/unit/query.spec.ts
packages/middleware-joi/test/unit/query.spec.ts
@@ -10,6 +10,10 @@ const reqMatched = (
) => ({ url, matchers, params, query } as any as HttpRequest);
describe('Joi middleware - Query', () => {
+ beforeEach(() => {
+ jest.spyOn(console, 'warn').mockImplementation(() => jest.fn());
+ });
+
test('should throws an error if dont pass a required field', done => {
expect.assertions(2);

MODIFY
packages/middleware-joi/test/unit/schema.spec.ts
packages/middleware-joi/test/unit/schema.spec.ts
@@ -3,6 +3,10 @@ import { Observable } from 'rxjs';
import { validator$ } from '../../src';
describe('Joi middleware - Schema', () => {
+ beforeEach(() => {
+ jest.spyOn(console, 'warn').mockImplementation(() => jest.fn());
+ });
+
it('should throws an error if using an invalid schema', done => {
const schema = { headers: 'foo' };
const http$ = validator$(schema)(undefined as unknown as Observable<HttpRequest>);
@@ -23,7 +27,6 @@ describe('Joi middleware - Schema', () => {
http$.subscribe(
() => {
fail('Exceptions should be thrown');
- done();
},
error => {
expect(error).toBeDefined();

test(middleware-joi): hide `console.warn` logs