문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판이전 판다음 판 | 이전 판 | ||
| study:script_test [2019/07/06 08:42] – [추가 플러그인] taekgu | study:script_test [2025/04/15 10:05] (현재) – 바깥 편집 127.0.0.1 | ||
|---|---|---|---|
| 줄 18: | 줄 18: | ||
| npm install --save-dev karma-jasmine karma-jasmine-html-reporter karma-mocha-reporter karma-webpack | npm install --save-dev karma-jasmine karma-jasmine-html-reporter karma-mocha-reporter karma-webpack | ||
| </ | </ | ||
| + | |||
| + | // 여기는 Tama가 추가 // | ||
| + | | ||
| + | npm install --save-dev @types/ | ||
| + | ** 기타 로더들 ** | ||
| + | * babel-loader | ||
| + | * css-loader | ||
| + | * style-loader | ||
| + | * ts-loader | ||
| + | |||
| ==== 2.karma.conf.js파일 생성 ==== | ==== 2.karma.conf.js파일 생성 ==== | ||
| '' | '' | ||
| 줄 217: | 줄 227: | ||
| // this file will be served on demand from disk and will be ignored by the watcher | // this file will be served on demand from disk and will be ignored by the watcher | ||
| - | {pattern: ' | + | {pattern: ' |
| + | {pattern: ' | ||
| + | {pattern: ' | ||
| + | {pattern: ' | ||
| + | / | ||
| + | watched: if autoWatch is true all files that have watched set to true will be watched for changes | ||
| + | served: should the files be served by Karma' | ||
| + | included: should the files be included in the browser using < | ||
| + | nocache: should the files be served from disk on each request by Karma' | ||
| + | /*assets: | ||
| + | {pattern: ' | ||
| + | {pattern: ' | ||
| ], | ], | ||
| </ | </ | ||
| 줄 225: | 줄 247: | ||
| karma-chrome-launcher: | karma-chrome-launcher: | ||
| - | ==== Install ==== | ||
| - | Now that we have gotten the why? out of the way, let’s see how we can go about implementing our own testing framework: | ||
| - | First and foremost, we’ll have to install the libraries that we wish to use to test our systems. | + | ==== mamajs의 karma.conf.js ==== |
| - | <code bash> | + | |
| - | npm install --save-dev mocha chai | + | |
| - | npm install --save-dev ts-node typescript | + | |
| - | npm install --save-dev @types/chai @types/ | + | |
| - | </ | + | |
| - | package.json | + | <code javascript |
| - | <code javascript> | + | // Karma configuration |
| - | " | + | // Generated on Mon Jun 03 2019 23:19:22 GMT+0900 (대한민국 표준시) |
| - | | + | const path = require(' |
| - | }, | + | var webpackConfig = require(' |
| - | </code> | + | |
| - | **Gulp** | + | module.exports = function(config) |
| - | We need to install two more packages | + | config.set({ |
| - | <code bash> | + | |
| - | npm install gulp gulp-mocha --save-dev | + | |
| + | basePath: '', | ||
| + | |||
| + | |||
| + | // frameworks to use | ||
| + | // available frameworks: https:// | ||
| + | frameworks: [' | ||
| + | |||
| + | | ||
| + | files: [ | ||
| + | {pattern: 'src/ | ||
| + | | ||
| + | | ||
| + | / | ||
| + | watched: if autoWatch is true all files that have watched set to true will be watched for changes | ||
| + | served: should the files be served by Karma' | ||
| + | included: should the files be included in the browser using <script> tag? | ||
| + | | ||
| + | /*assets: | ||
| + | {pattern: '*.html', | ||
| + | {pattern: ' | ||
| + | ], | ||
| + | |||
| + | // list of files / patterns | ||
| + | exclude: [ ], | ||
| + | |||
| + | // start these browsers | ||
| + | // available browser launchers: https:// | ||
| + | browsers: [' | ||
| + | |||
| + | // enable / disable watching file and executing tests whenever any file changes | ||
| + | autoWatch: true, | ||
| + | |||
| + | client: { | ||
| + | //capture all console output and pipe it to the terminal, true is default | ||
| + | captureConsole: | ||
| + | //if true, Karma clears the context window upon the completion of running the tests, true is default | ||
| + | clearContext: | ||
| + | //run the tests on the same window as the client, without using iframe or a new window, false is default | ||
| + | runInParent: | ||
| + | //true: runs the tests inside an iFrame; false: runs the tests in a new window, true is default | ||
| + | useIframe: | ||
| + | jasmine:{ | ||
| + | //tells jasmine | ||
| + | random: false | ||
| + | } | ||
| + | }, | ||
| + | // 여기부터 기본 init에서 수정 사항 | ||
| + | // 웹팩 설정 가져오기?? | ||
| + | webpack: { | ||
| + | mode: ' | ||
| + | //module: webpackConfig.module, | ||
| + | resolve: webpackConfig.resolve, | ||
| + | module: { | ||
| + | rules: [ | ||
| + | { | ||
| + | test: / | ||
| + | include: [ | ||
| + | path.resolve(__dirname, | ||
| + | ], | ||
| + | exclude: [/ | ||
| + | | ||
| + | | ||
| + | | ||
| + | presets: [' | ||
| + | // plugins: [' | ||
| + | } | ||
| + | } | ||
| + | }, | ||
| + | { | ||
| + | test: / | ||
| + | include: [ | ||
| + | path.resolve(__dirname, | ||
| + | ], | ||
| + | exclude: [/ | ||
| + | use: { | ||
| + | loader: ' | ||
| + | } | ||
| + | }, | ||
| + | { | ||
| + | test: / | ||
| + | use: [' | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | }, | ||
| + | |||
| + | // preprocess matching files before serving them to the browser | ||
| + | // available preprocessors: | ||
| + | preprocessors: | ||
| + | ' | ||
| + | ' | ||
| + | }, | ||
| + | |||
| + | // test results reporter to use | ||
| + | // possible values: ' | ||
| + | // available reporters: https:// | ||
| + | reporters: [' | ||
| + | |||
| + | |||
| + | // web server port | ||
| + | port: 9876, | ||
| + | |||
| + | |||
| + | // enable / disable colors in the output (reporters and logs) | ||
| + | colors: true, | ||
| + | |||
| + | |||
| + | // level of logging | ||
| + | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | ||
| + | //logLevel: config.LOG_INFO, | ||
| + | logLevel: config.LOG_ERROR, | ||
| + | |||
| + | // Continuous Integration mode | ||
| + | // if true, Karma captures browsers, runs the tests and exits | ||
| + | singleRun: false, | ||
| + | |||
| + | // Concurrency level | ||
| + | // how many browser should be started simultaneous | ||
| + | concurrency: | ||
| + | }) | ||
| + | } | ||
| </ | </ | ||
| - | ==== Script Test ==== | ||
| - | * Mocha / Chai | ||
| - | * Jasmine | ||
| - | * [[https:// | ||
| ===== Jasmine ===== | ===== Jasmine ===== | ||
| ** Behavior-Driven JavaScript ** | ** Behavior-Driven JavaScript ** | ||