-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug : jest, esbuild-jest
의 사용으로 인한 버그
#197
Comments
2. 파일 파싱 실패2.1. 한 일다음의 테스트 코드를 실행시켰습니다. import AuthController from "../../../../src/routes/controllers/auth.controller";
import { Request, Response, NextFunction } from "express";
import * as mockHttp from 'node-mocks-http';
jest.mock("../../../../src/routes/services/auth.service");
jest.mock("../../../../src/modules/validators/joi.validator");
describe('Auth Controller Test', () => {
let authController: AuthController;
let mockRequest: Request, mockResponse: Response, mockNextFunc: NextFunction;
beforeAll(() => {
authController = new AuthController();
});
beforeEach(() => {
mockRequest = mockHttp.createRequest();
mockResponse = mockHttp.createResponse();
mockNextFunc = jest.fn();
})
it("Authontroller be defined", () => expect(AuthController).toBeDefined());
it('authContro', () => {
authController.logout = jest.fn();
authController.logout(mockRequest, mockResponse, mockNextFunc);
});
}); 2.2. 에러 내용
2.3. 조치 사항본 이슈의 1.4. 조치 사항 B : 성공 - @babel/preset-typescript 설치 로 해결했습니다. |
jest, esbuild-jest
의 사용으로 인한 버그
해당 이슈는 해결되었습니다. |
1. jest, esbuild-jest 의 미사용 변수가 에러를 발생
1.1. 한 일
@axisotherwise
jest 의 성능 이슈 로 인해서 esbuild-jest 를 사용하였습니다.
30초, 반복 실행 38초그리고 다음과 같은 테스트용 유닛 테스트 를 작성했습니다.
1.2. 에러 내용
1.3. 조치 사항 A : 실패
import 구문을 사용하고 있을 때, type annotation 을 명시해버리면 에러가 나고 있습니다.
따라서, 파일의 11번 라인을 다음과 같이 변경하면 에러가 사라집니다.
해당 방식을 사용하면 authController 의 타입이 any 로 변경되어서, AuthController.prototype 이 가지고 있는 프로퍼티에 접근할 수 없습니다.
1.4. 조치 사항 B : 성공 - @babel/preset-typescript 설치
종속성 라이브러리인
@babel/preset-typescript
을 설치하고 프로젝트 루트 경로에 babel.config.json 을 생성했습니다.환경 설정
The text was updated successfully, but these errors were encountered: