Repository: nestjs/nest
Pull request #9814 (2022-06-20 15:54:08)

fix(integration,core): register native function aliases on repl feature
## PR Checklist
Please check if your PR fulfills the following requirements:

- [x] The commit message follows our guidelines: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md
- [x] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)


## PR Type
What kind of change does this PR introduce?

<!-- Please check the one that applies to this PR using "x". -->
- [x] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, local variables)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] CI related changes
- [x] Other... Please describe:

## What is the current behavior?

No integration tests for the alias `$` of `get` function from REPL feature.

The alias `$` was not registered as it should.

## Does this PR introduce a breaking change?
- [ ] Yes
- [x] No


Patch:
diff --git a/packages/common/interfaces/http/http-server.interface.ts b/packages/common/interfaces/http/http-server.interface.ts
index 99b7e55eb..d2e27de83 100644
--- a/packages/common/interfaces/http/http-server.interface.ts
+++ b/packages/common/interfaces/http/http-server.interface.ts
@@ -50,10 +50,8 @@ export interface HttpServer<TRequest = any, TResponse = any> {
   listen(port: number | string, hostname: string, callback?: () => void): any;
   reply(response: any, body: any, statusCode?: number): any;
   status(response: any, statusCode: number): any;
-  end(response: any, message?: string): any;
   render(response: any, view: string, options: any): any;
   redirect(response: any, statusCode: number, url: string): any;
-  isHeadersSent(response: any): boolean;
   setHeader(response: any, name: string, value: string): any;
   setErrorHandler?(handler: Function, prefix?: string): any;
   setNotFoundHandler?(handler: Function, prefix?: string): any;
diff --git a/packages/common/pipes/file/file-type.validator.ts b/packages/common/pipes/file/file-type.validator.ts
deleted file mode 100644
index 334049149..000000000
--- a/packages/common/pipes/file/file-type.validator.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import { FileValidator } from './file-validator.interface';
-
-export type FileTypeValidatorOptions = {
-  fileType: string;
-};
-
-/**
- * Defines the built-in FileType File Validator
- *
- * @see [File Validators](https://docs.nestjs.com/techniques/file-upload#validators)
- *
- * @publicApi
- */
-export class FileTypeValidator extends FileValidator<FileTypeValidatorOptions> {
-  buildErrorMessage(): string {
-    return `Validation failed (expected type is ${this.validationOptions.fileType})`;
-  }
-
-  isValid(file: any): boolean {
-    if (!this.validationOptions) {
-      return true;
-    }
-
-    if (!file.mimetype) {
-      return false;
-    }
-
-    return (file.mimetype as string).endsWith(this.validationOptions.fileType);
-  }
-}
diff --git a/packages/common/pipes/file/file-validator.interface.ts b/packages/common/pipes/file/file-validator.interface.ts
deleted file mode 100644
index ad453cdae..000000000
--- a/packages/common/pipes/file/file-validator.interface.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- * Interface describing FileValidators, which can be added to a {@link ParseFilePipe}.
- */
-export abstract class FileValidator<TValidationOptions = Record<string, any>> {
-  constructor(protected readonly validationOptions: TValidationOptions) {}
-
-  /**
-   * Indicates if this file should be considered valid, according to the options passed in the constructor.
-   * @param file the file from the request object
-   */
-  abstract isValid(file?: any): boolean | Promise<boolean>;
-
-  /**
-   * Builds an error message in case the validation fails.
-   * @param file the file from the request object
-   */
-  abstract buildErrorMessage(file: any): string;
-}
diff --git a/packages/common/pipes/file/index.ts b/packages/common/pipes/file/index.ts
deleted file mode 100644
index 11d19e318..000000000
--- a/packages/common/pipes/file/index.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-export * from './file-type.validator';
-export * from './file-validator.interface';
-export * from './max-file-size.validator';
-export * from './parse-file-options.interface';
-export * from './parse-file.pipe';
-export * from './parse-file-pipe.builder';
diff --git a/packages/common/pipes/file/max-file-size.validator.ts b/packages/common/pipes/file/max-file-size.validator.ts
deleted file mode 100644
index 847ee19f0..000000000
--- a/packages/common/pipes/file/max-file-size.validator.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { FileValidator } from './file-validator.interface';
-
-export type MaxFileSizeValidatorOptions = {
-  maxSize: number;
-};
-
-/**
- * Defines the built-in MaxSize File Validator
- *
- * @see [File Validators](https://docs.nestjs.com/techniques/file-upload#validators)
- *
- * @publicApi
- */
-export class MaxFileSizeValidator extends FileValidator<MaxFileSizeValidatorOptions> {
-  buildErrorMessage(): string {
-    return `Validation failed (expected size is less than ${this.validationOptions.maxSize})`;
-  }
-
-  public isValid(file: any): boolean {
-    if (!this.validationOptions) {
-      return true;
-    }
-
-    return file.size < this.validationOptions.maxSize;
-  }
-}
diff --git a/packages/common/pipes/file/parse-file-options.interface.ts b/packages/common/pipes/file/parse-file-options.interface.ts
deleted file mode 100644
index e74630999..000000000
--- a/packages/common/pipes/file/parse-file-options.interface.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { ErrorHttpStatusCode } from '../../utils/http-error-by-code.util';
-import { FileValidator } from './file-validator.interface';
-
-export interface ParseFileOptions {
-  validators?: FileValidator[];
-  errorHttpStatusCode?: ErrorHttpStatusCode;
-  exceptionFactory?: (error: string) => any;
-}
diff --git a/packages/common/pipes/file/parse-file-pipe.builder.ts b/packages/common/pipes/file/parse-file-pipe.builder.ts
deleted file mode 100644
index 7835322d9..000000000
--- a/packages/common/pipes/file/parse-file-pipe.builder.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import {
-  FileTypeValidator,
-  FileTypeValidatorOptions,
-} from './file-type.validator';
-import { FileValidator } from './file-validator.interface';
-import {
-  MaxFileSizeValidator,
-  MaxFileSizeValidatorOptions,
-} from './max-file-size.validator';
-import { ParseFileOptions } from './parse-file-options.interface';
-import { ParseFilePipe } from './parse-file.pipe';
-
-export class ParseFilePipeBuilder {
-  private validators: FileValidator[] = [];
-
-  addMaxSizeValidator(options: MaxFileSizeValidatorOptions) {
-    this.validators.push(new MaxFileSizeValidator(options));
-    return this;
-  }
-
-  addFileTypeValidator(options: FileTypeValidatorOptions) {
-    this.validators.push(new FileTypeValidator(options));
-    return this;
-  }
-
-  build(
-    additionalOptions?: Omit<ParseFileOptions, 'validators'>,
-  ): ParseFilePipe {
-    const parseFilePipe = new ParseFilePipe({
-      ...additionalOptions,
-      validators: this.validators,
-    });
-
-    this.validators = [];
-    return parseFilePipe;
-  }
-}
diff --git a/packages/common/pipes/file/parse-file.pipe.ts b/packages/common/pipes/file/parse-file.pipe.ts
deleted file mode 100644
index e952c38f5..000000000
--- a/packages/common/pipes/file/parse-file.pipe.ts
+++ /dev/null
@@ -1,68 +0,0 @@
-import { Injectable, Optional } from '../../decorators/core';
-import { HttpStatus } from '../../enums';
-import { HttpErrorByCode } from '../../utils/http-error-by-code.util';
-import { PipeTransform } from '../../interfaces/features/pipe-transform.interface';
-import { ParseFileOptions } from './parse-file-options.interface';
-import { FileValidator } from './file-validator.interface';
-import { throws } from 'assert';
-
-/**
- * Defines the built-in ParseFile Pipe. This pipe can be used to validate incoming files
- * with `@UploadedFile()` decorator. You can use either other specific built-in validators
- * or provide one of your own, simply implementing it through {@link FileValidator}
- * interface and adding it to ParseFilePipe's constructor.
- *
- * @see [Built-in Pipes](https://docs.nestjs.com/pipes#built-in-pipes)
- *
- * @publicApi
- */
-@Injectable()
-export class ParseFilePipe implements PipeTransform<any> {
-  protected exceptionFactory: (error: string) => any;
-  private readonly validators: FileValidator[];
-
-  constructor(@Optional() options: ParseFileOptions = {}) {
-    const {
-      exceptionFactory,
-      errorHttpStatusCode = HttpStatus.BAD_REQUEST,
-      validators = [],
-    } = options;
-
-    this.exceptionFactory =
-      exceptionFactory ||
-      (error => new HttpErrorByCode[errorHttpStatusCode](error));
-
-    this.validators = validators;
-  }
-
-  async transform(value: any): Promise<any> {
-    if (this.validators.length) {
-      await this.validate(value);
-    }
-    return value;
-  }
-
-  protected async validate(file: any): Promise<any> {
-    for (const validator of this.validators) {
-      await this.validateOrThrow(file, validator);
-    }
-
-    return file;
-  }
-
-  private async validateOrThrow(file: any, validator: FileValidator) {
-    const isValid = await validator.isValid(file);
-
-    if (!isValid) {
-      const errorMessage = validator.buildErrorMessage(file);
-      throw this.exceptionFactory(errorMessage);
-    }
-  }
-
-  /**
-   * @returns list of validators used in this pipe.
-   */
-  getValidators() {
-    return this.validators;
-  }
-}
diff --git a/packages/common/pipes/index.ts b/packages/common/pipes/index.ts
index ebbc55f27..a69365493 100644
--- a/packages/common/pipes/index.ts
+++ b/packages/common/pipes/index.ts
@@ -6,4 +6,3 @@ export * from './parse-float.pipe';
 export * from './parse-enum.pipe';
 export * from './parse-uuid.pipe';
 export * from './validation.pipe';
-export * from './file';
diff --git a/packages/core/adapters/http-adapter.ts b/packages/core/adapters/http-adapter.ts
index ab94905a2..449c9e68c 100644
--- a/packages/core/adapters/http-adapter.ts
+++ b/packages/core/adapters/http-adapter.ts
@@ -105,12 +105,10 @@ export abstract class AbstractHttpAdapter<
   abstract getRequestUrl(request);
   abstract status(response, statusCode: number);
   abstract reply(response, body: any, statusCode?: number);
-  abstract end(response, message?: string);
   abstract render(response, view: string, options: any);
   abstract redirect(response, statusCode: number, url: string);
   abstract setErrorHandler(handler: Function, prefix?: string);
   abstract setNotFoundHandler(handler: Function, prefix?: string);
-  abstract isHeadersSent(response);
   abstract setHeader(response, name: string, value: string);
   abstract registerParserMiddleware(prefix?: string, rawBody?: boolean);
   abstract enableCors(
diff --git a/packages/core/exceptions/base-exception-filter.ts b/packages/core/exceptions/base-exception-filter.ts
index bc3784501..ea360e84a 100644
--- a/packages/core/exceptions/base-exception-filter.ts
+++ b/packages/core/exceptions/base-exception-filter.ts
@@ -38,12 +38,7 @@ export class BaseExceptionFilter<T = any> implements ExceptionFilter<T> {
           message: res,
         };
 
-    const response = host.getArgByIndex(1);
-    if (!applicationRef.isHeadersSent(response)) {
-      applicationRef.reply(response, message, exception.getStatus());
-    } else {
-      applicationRef.end(response);
-    }
+    applicationRef.reply(host.getArgByIndex(1), message, exception.getStatus());
   }
 
   public handleUnknownError(
@@ -60,14 +55,7 @@ export class BaseExceptionFilter<T = any> implements ExceptionFilter<T> {
           statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
           message: MESSAGES.UNKNOWN_EXCEPTION_MESSAGE,
         };
-
-    const response = host.getArgByIndex(1);
-    if (!applicationRef.isHeadersSent(response)) {
-      applicationRef.reply(response, body, body.statusCode);
-    } else {
-      applicationRef.end(response);
-    }
-
+    applicationRef.reply(host.getArgByIndex(1), body, body.statusCode);
     if (this.isExceptionObject(exception)) {
       return BaseExceptionFilter.logger.error(
         exception.message,
diff --git a/packages/core/repl/repl-context.ts b/packages/core/repl/repl-context.ts
index 7a8696cae..f8eef91a8 100644
--- a/packages/core/repl/repl-context.ts
+++ b/packages/core/repl/repl-context.ts
@@ -114,8 +114,9 @@ export class ReplContext {
 
   private addNativeFunction(
     NativeFunctionRef: ReplFunctionClass,
-  ): InstanceType<ReplFunctionClass> {
+  ): InstanceType<ReplFunctionClass>[] {
     const nativeFunction = new NativeFunctionRef(this);
+    const nativeFunctions = [nativeFunction];
 
     this.nativeFunctions.set(nativeFunction.fnDefinition.name, nativeFunction);
 
@@ -128,9 +129,10 @@ export class ReplContext {
         signature: aliasNativeFunction.fnDefinition.signature,
       };
       this.nativeFunctions.set(aliaseName, aliasNativeFunction);
+      nativeFunctions.push(aliasNativeFunction);
     });
 
-    return nativeFunction;
+    return nativeFunctions;
   }
 
   private registerFunctionIntoGlobalScope(
@@ -168,8 +170,10 @@ export class ReplContext {
     builtInFunctionsClassRefs
       .concat(nativeFunctionsClassRefs)
       .forEach(NativeFunction => {
-        const nativeFunction = this.addNativeFunction(NativeFunction);
-        this.registerFunctionIntoGlobalScope(nativeFunction);
+        const nativeFunctions = this.addNativeFunction(NativeFunction);
+        nativeFunctions.forEach(nativeFunction => {
+          this.registerFunctionIntoGlobalScope(nativeFunction);
+        });
       });
   }
 }
diff --git a/packages/platform-express/adapters/express-adapter.ts b/packages/platform-express/adapters/express-adapter.ts
index 9bb80c5b1..2bd9b226c 100644
--- a/packages/platform-express/adapters/express-adapter.ts
+++ b/packages/platform-express/adapters/express-adapter.ts
@@ -85,10 +85,6 @@ export class ExpressAdapter extends AbstractHttpAdapter {
     return response.status(statusCode);
   }
 
-  public end(response: any, message?: string) {
-    return response.end(message);
-  }
-
   public render(response: any, view: string, options: any) {
     return response.render(view, options);
   }
@@ -105,10 +101,6 @@ export class ExpressAdapter extends AbstractHttpAdapter {
     return this.use(handler);
   }
 
-  public isHeadersSent(response: any): boolean {
-    return response.headersSent;
-  }
-
   public setHeader(response: any, name: string, value: string) {
     return response.set(name, value);
   }
diff --git a/packages/platform-fastify/adapters/fastify-adapter.ts b/packages/platform-fastify/adapters/fastify-adapter.ts
index caeae3e68..96497c654 100644
--- a/packages/platform-fastify/adapters/fastify-adapter.ts
+++ b/packages/platform-fastify/adapters/fastify-adapter.ts
@@ -325,10 +325,6 @@ export class FastifyAdapter<
     return (response as TReply).code(statusCode);
   }
 
-  public end(response: TReply, message?: string) {
-    response.raw.end(message);
-  }
-
   public render(
     response: TReply & { view: Function },
     view: string,
@@ -413,10 +409,6 @@ export class FastifyAdapter<
     );
   }
 
-  public isHeadersSent(response: TReply): boolean {
-    return response.sent;
-  }
-
   public setHeader(response: TReply, name: string, value: string) {
     return response.header(name, value);
   }
diff --git a/sample/29-file-upload/src/app.controller.ts b/sample/29-file-upload/src/app.controller.ts
index 39d3af1fb..dc59cd260 100644
--- a/sample/29-file-upload/src/app.controller.ts
+++ b/sample/29-file-upload/src/app.controller.ts
@@ -2,7 +2,6 @@ import {
   Body,
   Controller,
   Get,
-  ParseFilePipeBuilder,
   Post,
   UploadedFile,
   UseInterceptors,
@@ -32,42 +31,4 @@ export class AppController {
       file: file.buffer.toString(),
     };
   }
-
-  @UseInterceptors(FileInterceptor('file'))
-  @Post('file/pass-validation')
-  uploadFileAndPassValidation(
-    @Body() body: SampleDto,
-    @UploadedFile(
-      new ParseFilePipeBuilder()
-        .addFileTypeValidator({
-          fileType: 'json',
-        })
-        .build(),
-    )
-    file: Express.Multer.File,
-  ) {
-    return {
-      body,
-      file: file.buffer.toString(),
-    };
-  }
-
-  @UseInterceptors(FileInterceptor('file'))
-  @Post('file/fail-validation')
-  uploadFileAndFailValidation(
-    @Body() body: SampleDto,
-    @UploadedFile(
-      new ParseFilePipeBuilder()
-        .addFileTypeValidator({
-          fileType: 'jpg',
-        })
-        .build(),
-    )
-    file: Express.Multer.File,
-  ) {
-    return {
-      body,
-      file: file.buffer.toString(),
-    };
-  }
 }


Test patch:
diff --git a/integration/repl/e2e/repl.spec.ts b/integration/repl/e2e/repl.spec.ts
index 8c20d3a79..03693f296 100644
--- a/integration/repl/e2e/repl.spec.ts
+++ b/integration/repl/e2e/repl.spec.ts
@@ -31,7 +31,7 @@ describe('REPL', () => {
 
   it('get()', async () => {
     const server = await repl(AppModule);
-    server.context
+    server.context;
     let outputText = '';
     sinon.stub(process.stdout, 'write').callsFake(text => {
       outputText += text;
@@ -58,6 +58,35 @@ ${PROMPT}`);
 ${PROMPT}`);
   });
 
+  it('$()', async () => {
+    const server = await repl(AppModule);
+    server.context;
+    let outputText = '';
+    sinon.stub(process.stdout, 'write').callsFake(text => {
+      outputText += text;
+      return true;
+    });
+    server.emit('line', '$(UsersService)');
+
+    expect(outputText).to.equal(
+      `UsersService { usersRepository: UsersRepository {} }
+${PROMPT}`,
+    );
+
+    outputText = '';
+    server.emit('line', '$(UsersService).findAll()');
+
+    expect(outputText).to
+      .equal(`\u001b[32m'This action returns all users'\u001b[39m
+${PROMPT}`);
+
+    outputText = '';
+    server.emit('line', '$(UsersRepository)');
+
+    expect(outputText).to.equal(`UsersRepository {}
+${PROMPT}`);
+  });
+
   it('debug()', async () => {
     const server = await repl(AppModule);
 
diff --git a/packages/common/test/pipes/file/file-type.validator.spec.ts b/packages/common/test/pipes/file/file-type.validator.spec.ts
deleted file mode 100644
index c4248f66a..000000000
--- a/packages/common/test/pipes/file/file-type.validator.spec.ts
+++ /dev/null
@@ -1,65 +0,0 @@
-import { FileTypeValidator } from '../../../pipes';
-import { expect } from 'chai';
-
-describe('FileTypeValidator', () => {
-  describe('isValid', () => {
-    it('should return true when the file mimetype is the same as the specified', () => {
-      const fileTypeValidator = new FileTypeValidator({
-        fileType: 'image/jpeg',
-      });
-
-      const requestFile = {
-        mimetype: 'image/jpeg',
-      };
-
-      expect(fileTypeValidator.isValid(requestFile)).to.equal(true);
-    });
-
-    it('should return true when the file mimetype ends with the specified option type', () => {
-      const fileTypeValidator = new FileTypeValidator({
-        fileType: 'jpeg',
-      });
-
-      const requestFile = {
-        mimetype: 'image/jpeg',
-      };
-
-      expect(fileTypeValidator.isValid(requestFile)).to.equal(true);
-    });
-
-    it('should return false when the file mimetype is different from the specified', () => {
-      const fileTypeValidator = new FileTypeValidator({
-        fileType: 'image/jpeg',
-      });
-
-      const requestFile = {
-        mimetype: 'image/png',
-      };
-
-      expect(fileTypeValidator.isValid(requestFile)).to.equal(false);
-    });
-
-    it('should return false when the file mimetype was not provided', () => {
-      const fileTypeValidator = new FileTypeValidator({
-        fileType: 'image/jpeg',
-      });
-
-      const requestFile = {};
-
-      expect(fileTypeValidator.isValid(requestFile)).to.equal(false);
-    });
-  });
-
-  describe('buildErrorMessage', () => {
-    it('should return a string with the format "Validation failed (expected type is #fileType)"', () => {
-      const fileType = 'image/jpeg';
-      const fileTypeValidator = new FileTypeValidator({
-        fileType,
-      });
-
-      expect(fileTypeValidator.buildErrorMessage()).to.equal(
-        `Validation failed (expected type is ${fileType})`,
-      );
-    });
-  });
-});
diff --git a/packages/common/test/pipes/file/max-file-size.validator.spec.ts b/packages/common/test/pipes/file/max-file-size.validator.spec.ts
deleted file mode 100644
index 9ba8e4283..000000000
--- a/packages/common/test/pipes/file/max-file-size.validator.spec.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-import { expect } from 'chai';
-import { MaxFileSizeValidator } from '../../../pipes';
-
-describe('MaxFileSizeValidator', () => {
-  const oneKb = 1024;
-
-  describe('isValid', () => {
-    it('should return true when the file size is less than the maximum size', () => {
-      const maxFileSizeValidator = new MaxFileSizeValidator({
-        maxSize: oneKb,
-      });
-
-      const requestFile = {
-        size: 100,
-      };
-
-      expect(maxFileSizeValidator.isValid(requestFile)).to.equal(true);
-    });
-
-    it('should return false when the file size is greater than the maximum size', () => {
-      const maxFileSizeValidator = new MaxFileSizeValidator({
-        maxSize: oneKb,
-      });
-
-      const requestFile = {
-        size: oneKb + 1,
-      };
-
-      expect(maxFileSizeValidator.isValid(requestFile)).to.equal(false);
-    });
-
-    it('should return false when the file size is equal to the maximum size', () => {
-      const maxFileSizeValidator = new MaxFileSizeValidator({
-        maxSize: oneKb,
-      });
-
-      const requestFile = {
-        size: oneKb,
-      };
-
-      expect(maxFileSizeValidator.isValid(requestFile)).to.equal(false);
-    });
-  });
-
-  describe('buildErrorMessage', () => {
-    it('should return a string with the format "Validation failed (expected size is less than #maxSize")', () => {
-      const maxFileSizeValidator = new MaxFileSizeValidator({
-        maxSize: oneKb,
-      });
-
-      expect(maxFileSizeValidator.buildErrorMessage()).to.equal(
-        `Validation failed (expected size is less than ${oneKb})`,
-      );
-    });
-  });
-});
diff --git a/packages/common/test/pipes/file/parse-file-pipe.builder.spec.ts b/packages/common/test/pipes/file/parse-file-pipe.builder.spec.ts
deleted file mode 100644
index 8c31904aa..000000000
--- a/packages/common/test/pipes/file/parse-file-pipe.builder.spec.ts
+++ /dev/null
@@ -1,77 +0,0 @@
-import { expect } from 'chai';
-import {
-  FileTypeValidator,
-  MaxFileSizeValidator,
-  ParseFilePipeBuilder,
-} from '../../../pipes';
-
-describe('ParseFilePipeBuilder', () => {
-  let parseFilePipeBuilder: ParseFilePipeBuilder;
-
-  beforeEach(() => {
-    parseFilePipeBuilder = new ParseFilePipeBuilder();
-  });
-
-  describe('build', () => {
-    describe('when no validator was passed', () => {
-      it('should return a ParseFilePipe with no validators', () => {
-        const parseFilePipe = parseFilePipeBuilder.build();
-        expect(parseFilePipe.getValidators()).to.be.empty;
-      });
-    });
-
-    describe('when addMaxSizeValidator was chained', () => {
-      it('should return a ParseFilePipe with MaxSizeValidator and given options', () => {
-        const options = {
-          maxSize: 1000,
-        };
-        const parseFilePipe = parseFilePipeBuilder
-          .addMaxSizeValidator(options)
-          .build();
-
-        expect(parseFilePipe.getValidators()).to.deep.include(
-          new MaxFileSizeValidator(options),
-        );
-      });
-    });
-
-    describe('when addFileTypeValidator was chained', () => {
-      it('should return a ParseFilePipe with FileTypeValidator and given options', () => {
-        const options = {
-          fileType: 'image/jpeg',
-        };
-        const parseFilePipe = parseFilePipeBuilder
-          .addFileTypeValidator(options)
-          .build();
-
-        expect(parseFilePipe.getValidators()).to.deep.include(
-          new FileTypeValidator(options),
-        );
-      });
-    });
-
-    describe('when it is called twice with different validators', () => {
-      it('should not reuse validators', () => {
-        const maxSizeValidatorOptions = {
-          maxSize: 1000,
-        };
-
-        const pipeWithMaxSizeValidator = parseFilePipeBuilder
-          .addMaxSizeValidator(maxSizeValidatorOptions)
-          .build();
-
-        const fileTypeValidatorOptions = {
-          fileType: 'image/jpeg',
-        };
-
-        const pipeWithFileTypeValidator = parseFilePipeBuilder
-          .addFileTypeValidator(fileTypeValidatorOptions)
-          .build();
-
-        expect(pipeWithFileTypeValidator.getValidators()).not.to.deep.equal(
-          pipeWithMaxSizeValidator.getValidators(),
-        );
-      });
-    });
-  });
-});
diff --git a/packages/common/test/pipes/file/parse-file.pipe.spec.ts b/packages/common/test/pipes/file/parse-file.pipe.spec.ts
deleted file mode 100644
index ee06ef44b..000000000
--- a/packages/common/test/pipes/file/parse-file.pipe.spec.ts
+++ /dev/null
@@ -1,120 +0,0 @@
-import { HttpStatus } from '../../../enums';
-import { BadRequestException, ConflictException } from '../../../exceptions';
-import { FileValidator, ParseFilePipe } from '../../../pipes';
-import { expect } from 'chai';
-
-class AlwaysValidValidator extends FileValidator {
-  isValid(): boolean {
-    return true;
-  }
-  buildErrorMessage(): string {
-    return '';
-  }
-}
-
-const customErrorMessage = 'Error!';
-
-class AlwaysInvalidValidator extends FileValidator {
-  isValid(): boolean {
-    return false;
-  }
-  buildErrorMessage(): string {
-    return customErrorMessage;
-  }
-}
-
-describe('ParseFilePipe', () => {
-  let parseFilePipe: ParseFilePipe;
-  describe('transform', () => {
-    describe('when there are no validators (explicit)', () => {
-      beforeEach(() => {
-        parseFilePipe = new ParseFilePipe({
-          validators: [],
-        });
-      });
-
-      it('should return the file object', async () => {
-        const requestFile = {
-          path: 'some-path',
-        };
-
-        await expect(parseFilePipe.transform(requestFile)).to.eventually.eql(
-          requestFile,
-        );
-      });
-    });
-
-    describe('when there are no validators (by default constructor)', () => {
-      beforeEach(() => {
-        parseFilePipe = new ParseFilePipe();
-      });
-
-      it('should return the file object', async () => {
-        const requestFile = {
-          path: 'some-path',
-        };
-
-        await expect(parseFilePipe.transform(requestFile)).to.eventually.eql(
-          requestFile,
-        );
-      });
-    });
-
-    describe('when all the validators validate the file', () => {
-      beforeEach(() => {
-        parseFilePipe = new ParseFilePipe({
-          validators: [new AlwaysValidValidator({})],
-        });
-      });
-
-      it('should return the file object', async () => {
-        const requestFile = {
-          path: 'some-path',
-        };
-
-        await expect(parseFilePipe.transform(requestFile)).to.eventually.eql(
-          requestFile,
-        );
-      });
-    });
-
-    describe('when some validator invalidates the file', () => {
-      describe('and the pipe has the default error', () => {
-        beforeEach(() => {
-          parseFilePipe = new ParseFilePipe({
-            validators: [new AlwaysInvalidValidator({})],
-          });
-        });
-
-        it('should throw a BadRequestException', async () => {
-          const requestFile = {
-            path: 'some-path',
-          };
-
-          await expect(parseFilePipe.transform(requestFile)).to.be.rejectedWith(
-            BadRequestException,
-          );
-        });
-      });
-
-      describe('and the pipe has a custom error code', () => {
-        beforeEach(() => {
-          parseFilePipe = new ParseFilePipe({
-            validators: [new AlwaysInvalidValidator({})],
-            errorHttpStatusCode: HttpStatus.CONFLICT,
-          });
-        });
-
-        it('should throw this custom Error', async () => {
-          const requestFile = {
-            path: 'some-path',
-          };
-
-          await expect(parseFilePipe.transform(requestFile)).to.be.rejectedWith(
-            ConflictException,
-          );
-        });
-      });
-    });
-  });
-});
diff --git a/packages/core/test/utils/noop-adapter.spec.ts b/packages/core/test/utils/noop-adapter.spec.ts
index dc7daecb2..4935a53ee 100644
--- a/packages/core/test/utils/noop-adapter.spec.ts
+++ b/packages/core/test/utils/noop-adapter.spec.ts
@@ -14,13 +14,11 @@ export class NoopHttpAdapter extends AbstractHttpAdapter {
   getRequestMethod(request: any): any {}
   getRequestUrl(request: any): any {}
   reply(response: any, body: any): any {}
-  end(response: any, message?: any): any {}
   status(response: any, statusCode: number): any {}
   render(response: any, view: string, options: any): any {}
   redirect(response: any, statusCode: number, url: string) {}
   setErrorHandler(handler: Function, prefix = '/'): any {}
   setNotFoundHandler(handler: Function, prefix = '/'): any {}
-  isHeadersSent(response: any): any {}
   setHeader(response: any, name: string, value: string): any {}
   registerParserMiddleware(): any {}
   enableCors(options: any): any {}
diff --git a/sample/29-file-upload/e2e/app/app.e2e-spec.ts b/sample/29-file-upload/e2e/app/app.e2e-spec.ts
index 4107251ff..826b5ba8d 100644
--- a/sample/29-file-upload/e2e/app/app.e2e-spec.ts
+++ b/sample/29-file-upload/e2e/app/app.e2e-spec.ts
@@ -1,6 +1,7 @@
 import { INestApplication } from '@nestjs/common';
 import { Test } from '@nestjs/testing';
 import { readFileSync } from 'fs';
+import { join } from 'path';
 import * as request from 'supertest';
 import { AppModule } from '../../src/app.module';
 
@@ -29,28 +30,6 @@ describe('E2E FileTest', () => {
       });
   });
 
-  it('should allow for file uploads that pass validation', async () => {
-    return request(app.getHttpServer())
-      .post('/file/pass-validation')
-      .attach('file', './package.json')
-      .field('name', 'test')
-      .expect(201)
-      .expect({
-        body: {
-          name: 'test',
-        },
-        file: readFileSync('./package.json').toString(),
-      });
-  });
-
-  it('should throw for file uploads that do not pass validation', async () => {
-    return request(app.getHttpServer())
-      .post('/file/fail-validation')
-      .attach('file', './package.json')
-      .field('name', 'test')
-      .expect(400);
-  });
-
   afterAll(async () => {
     await app.close();
   });