$nest new nest-app
nest-app으로 nestjs 프로젝트를 생성하고,
PS C:\dev\nest-app> npm run test:cov
>> # test coverage
>> npm run test:e2e
>> # e2e tests
>> npm run test
>> # unit tests
> nest-app@0.0.1 test:cov C:\dev\nest-app
> jest --coverage
PASS src/app.controller.spec.ts
AppController
root
√ should return "Hello World!" (18 ms)
-------------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------------|---------|----------|---------|---------|-------------------
All files | 54.16 | 100 | 75 | 50 |
app.controller.ts | 100 | 100 | 100 | 100 |
app.module.ts | 0 | 100 | 100 | 0 | 1-10
app.service.ts | 100 | 100 | 100 | 100 |
main.ts | 0 | 100 | 0 | 0 | 1-8
-------------------|---------|----------|---------|---------|-------------------
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 8.578 s
Ran all test suites.
> nest-app@0.0.1 test:e2e C:\dev\nest-app
> jest --config ./test/jest-e2e.json
파일들이 생성되고 테스트 실행도 제공해준다.
PS C:\dev\nest-app> nest
Usage: nest
nest라고 치면 쓸 수 있는 cli명령어와 alias가 나온다 예를들어 새로운 컨트롤러를 만들때는, nest g co 라고 친다. 컨트롤러 이름을 묻는 질문에 원하는 이름을 치면 디렉토리와 컨트롤러가 이름에 맞게 생성된다.
PS C:\dev\nest-app> nest g co
? What name would you like to use for the controller? greeting
CREATE src/greeting/greeting.controller.spec.ts (492 bytes)
CREATE src/greeting/greeting.controller.ts (101 bytes)
UPDATE src/app.module.ts (211 bytes)
'개발관련 > NestJS' 카테고리의 다른 글
NestJS 설치 (+에러 해결법) (0) | 2023.08.08 |
---|