라벨이 try인 게시물 표시

TypeScript_JEST TypeScript로 Node TestCast만들기 : 에러상황을 테스트하기 -3

이미지
  // src/app/Main.ts import { parse , UrlWithParsedQuery } from "url" ; export class Fun { public static parseUrl ( url : string ) : UrlWithParsedQuery { if (! url || url . length <= 0 ) throw Error ( 'url is empty' ) // url이 비어있을시 에러발생 return parse ( url , true ); } public static toUpperC ( arg : string ){ return arg . toUpperCase (); } } // src/test/Main.test.ts import { Fun } from '../app/Main' describe ( 'Main test suite' , () => { // 해당 describe테스트에서 아래만 제외한다. test ( 'first test' , () => { console . log ( 'test work!!!' ) const str = Fun . toUpperC ( 'str' ); expect ( str ). toBe ( 'STR' ); // Fun.toUpper의 결과가 문자열 STR 이어야 한다 }); test ( 'parse URL' , () => { const url : string = 'http://localhost:3000/signup' ; const port : string = url . split ( 'localhost:...