"Node.js"의 두 판 사이의 차이

오픈소스 비즈니스 컨설팅
둘러보기로 가기 검색하러 가기
잔글
잔글
40번째 줄: 40번째 줄:
  
  
<span style="color:#008000;"><span style="font-size:larger;">Test Framework 설치 및 설정</span></span>
+
<span style="color:#008000;"><span style="font-size:larger;">Karma 모듈을 설치 합니다.</span></span>
  
npm -g install&nbsp;karma --save-dev
+
*설정 파일 :&nbsp;karma.conf.js,&nbsp;test-main.js
 +
*테스트 모듈 실행 : karma start karma-conf.js
  
npm install karma-coverage --save-dev
+
npm install karma-cli -g<br/>npm install karma -g --save-dev<br/>npm install karma-coverage --save-dev<br/>npm install karma-jasmine --save-dev<br/># npm install karma-chrome-launcher --save-dev<br/>karma --version
 +
 
 +
karma init karma.conf.js<br/># Which testing framework do you want to use ? jasmine<br/># Do you want to use Require.js ? yes<br/># Do you want to capture any browsers automatically ? Chrome<br/># What is the location of your source and test files ?<br/># Should any of the files included by the previous patterns be excluded ?<br/># Do you wanna generate a bootstrap file for RequireJS? yes<br/># Do you want Karma to watch all the files and run the tests on change ? yes
 +
 
 +
환경 변수 설정&nbsp;: CHROME_BIN = chrome.exe
  
npm install karma-jasmine --save-dev
 
  
npm install karma-chrome-launcher --save-dev
 
  
환경 변수 설정&nbsp;: CHROME_BIN = chrome.exe
+
<span style="color: rgb(0, 128, 0); font-size: 15.6000003814697px; line-height: 24.9600009918213px;">Jasmine 모듈을 설치 합니다.</span>
 +
 
 +
*설정 파일 : spec/support/jasmine.json
 +
*테스트 모듈 실행&nbsp;
 +
**js/sample.js, test/sampleSpec.js
 +
**모든 Test 프로그램은 ~Spec.js 형태로 작성하여야 합니다.
 +
**jasmine-node --test-dir test --color --verbose
 +
**jasmine-node --test-dir test --autotest --watch test --color
 +
 
 +
npm install jasmine -g<br/>jasmine init
 +
 
 +
npm install jasmine-node -g<br/>jasmine-node --version
  
 
<br/>참고 문헌
 
<br/>참고 문헌
57번째 줄: 71번째 줄:
 
**[http://programmingsummaries.tistory.com/327 http://programmingsummaries.tistory.com/327]
 
**[http://programmingsummaries.tistory.com/327 http://programmingsummaries.tistory.com/327]
 
**[http://mobicon.tistory.com/407 http://mobicon.tistory.com/407]
 
**[http://mobicon.tistory.com/407 http://mobicon.tistory.com/407]
**http://webframeworks.kr/tutorials/angularjs/angularjs_unit_test/
+
**[http://webframeworks.kr/tutorials/angularjs/angularjs_unit_test/ http://webframeworks.kr/tutorials/angularjs/angularjs_unit_test/]
 
*Mocha
 
*Mocha
 
**[http://blog.outsider.ne.kr/770 http://blog.outsider.ne.kr/770]
 
**[http://blog.outsider.ne.kr/770 http://blog.outsider.ne.kr/770]

2015년 4월 2일 (목) 10:07 판

Server Side JavaScript인 Node.js를 정리 합니다.

Node.js 개요

Node.js는 서버사이드 자바스크립트이며 Google의 자바스크립트 엔진인 V8이 빌트인되어 있습니다. Event 기반이며 non-blocking I/O를 지원합니다. 자바스크립트의 표준라이브러리 프로젝트인 CommonJS의모듈시스템을 지원합니다.

  • Event loop 방식
  • 동작 요청시 동작이 완료될 경우에 실행될 Call Back을 지정하는 방식

Node.js 설치

CentOS에서 설치

yum install nodejs npm

Windows에서 설치

다운로드 사이트에서 node-v0.12.0-x64.msi 파일을 다운로드 하여 설치 합니다.

Console

node 명령을 사용하여 node Console을 실행할 수 있습니다.

종료시에는 process.exit(0); 또는 Ctrl_C + Ctrl_C를 눌러 줍니다.

Test Framework

테스트 방식

  • TDD (Test-Driven Development) : 테스트 자체에 집중
  • BDD (Behaviour-Driven Development) : 비즈니스 요구 사항에 집중


Karma 모듈을 설치 합니다.

  • 설정 파일 : karma.conf.js, test-main.js
  • 테스트 모듈 실행 : karma start karma-conf.js

npm install karma-cli -g
npm install karma -g --save-dev
npm install karma-coverage --save-dev
npm install karma-jasmine --save-dev
# npm install karma-chrome-launcher --save-dev
karma --version

karma init karma.conf.js
# Which testing framework do you want to use ? jasmine
# Do you want to use Require.js ? yes
# Do you want to capture any browsers automatically ? Chrome
# What is the location of your source and test files ?
# Should any of the files included by the previous patterns be excluded ?
# Do you wanna generate a bootstrap file for RequireJS? yes
# Do you want Karma to watch all the files and run the tests on change ? yes

환경 변수 설정 : CHROME_BIN = chrome.exe


Jasmine 모듈을 설치 합니다.

  • 설정 파일 : spec/support/jasmine.json
  • 테스트 모듈 실행 
    • js/sample.js, test/sampleSpec.js
    • 모든 Test 프로그램은 ~Spec.js 형태로 작성하여야 합니다.
    • jasmine-node --test-dir test --color --verbose
    • jasmine-node --test-dir test --autotest --watch test --color

npm install jasmine -g
jasmine init

npm install jasmine-node -g
jasmine-node --version


참고 문헌

참고 문헌