Ubuntu에 react Test 자동화를 해보자!
환경
VirtualBox
ubuntu-18.04.1-desktop-amd64.iso
karam & jasmin
Ubuntu 설치
Kernel driver not installed (rc=-1908) Make sure the kernel module has been loaded successfully. where: suplibOsInit what: 3 VERR_VM_DRIVER_NOT_INSTALLED (-1908) - The support driver is not installed. On linux, open returned ENOENT. VM 실행 시에 다음과 같은 Error가 발생할 수 있다. 그럴 땐 시스템 환경설정 > 보안 및 개인정보 보호에 진입해서 Oracle 앱 허용을 해줘야 한다. |
karam.conf.js
// Karma configuration
// Generated on Fri Nov 23 2018 12:15:54 GMT+0900 (KST)
var path = require('path')
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['browserify','jasmine'],
// list of files / patterns to load in the browser
files: [
'*.js'
],
// list of files / patterns to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'*.js': ['browserify']
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// 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,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['PhantomJS'],
// 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: Infinity
})
}
|
package.json
|
깔끔하게 library 설치 방법
rm -rf node_modules/ npm cache clean npm install |
실행
karma start karma.conf.js --browsers PhantomJS --single-run --log-level debug |
Output
26 11 2018 14:48:48.212:DEBUG [config]: Loading config /home/joe/karma/mobile-web-react/karma.conf.js
26 11 2018 14:48:48.216:DEBUG [config]: autoWatch set to false, because of singleRun
26 11 2018 14:48:48.217:DEBUG [karma-server]: Final config {
"LOG_DISABLE": "OFF",
"LOG_ERROR": "ERROR",
"LOG_WARN": "WARN",
"LOG_INFO": "INFO",
"LOG_DEBUG": "DEBUG",
"frameworks": [
"browserify",
"jasmine"
],
"protocol": "http:",
"port": 9876,
"listenAddress": "0.0.0.0",
"hostname": "localhost",
"httpsServerConfig": {},
"basePath": "/home/joe/karma/mobile-web-react",
"files": [
{
"pattern": "/home/joe/karma/mobile-web-react/*.js",
"served": true,
"included": true,
"watched": true,
"nocache": false,
"weight": [
1,
0,
1,
0,
0,
0
]
}
],
"browserConsoleLogOptions": {
"level": "debug",
"format": "%b %T: %m",
"terminal": true
},
"customContextFile": null,
"customDebugFile": null,
"customClientContextFile": null,
"exclude": [
"/home/joe/karma/mobile-web-react/karma.conf.js"
],
"logLevel": "DEBUG",
"colors": true,
"autoWatch": false,
"autoWatchBatchDelay": 250,
"restartOnFileChange": false,
"usePolling": true,
"reporters": [
"progress"
],
"singleRun": true,
"browsers": [
"PhantomJS"
],
"captureTimeout": 60000,
"proxies": {},
"proxyValidateSSL": true,
"preprocessors": {
"/home/joe/karma/mobile-web-react/*.js": [
"browserify"
]
},
"urlRoot": "/",
"reportSlowerThan": 0,
"loggers": [
{
"type": "console",
"layout": {
"type": "pattern",
"pattern": "%[%d{DATE}:%p [%c]: %]%m"
}
}
],
"transports": [
"polling",
"websocket"
],
"forceJSONP": false,
"plugins": [
"karma-*"
],
"client": {
"args": [],
"useIframe": true,
"runInParent": false,
"captureConsole": true,
"clearContext": true
},
"defaultClient": {
"args": [],
"useIframe": true,
"runInParent": false,
"captureConsole": true,
"clearContext": true
},
"browserDisconnectTimeout": 2000,
"browserDisconnectTolerance": 0,
"browserNoActivityTimeout": 30000,
"processKillTimeout": 2000,
"concurrency": null,
"failOnEmptyTestSuite": true,
"retryLimit": 2,
"detached": false,
"crossOriginAttribute": true,
"browserSocketTimeout": 20000,
"cmd": "start",
"configFile": "/home/joe/karma/mobile-web-react/karma.conf.js"
}
26 11 2018 14:48:48.220:DEBUG [plugin]: Loading karma-* from /usr/local/lib/node_modules
26 11 2018 14:48:48.220:DEBUG [plugin]: Loading plugin /usr/local/lib/node_modules/karma-browserify.
26 11 2018 14:48:48.431:DEBUG [plugin]: Loading plugin /usr/local/lib/node_modules/karma-coverage.
26 11 2018 14:48:48.693:DEBUG [plugin]: Loading plugin /usr/local/lib/node_modules/karma-jasmine.
26 11 2018 14:48:48.696:DEBUG [plugin]: Loading plugin /usr/local/lib/node_modules/karma-phantomjs-launcher.
26 11 2018 14:48:48.764:DEBUG [framework.browserify]: created browserify bundle: /tmp/1830825872ce6d6f085118f36ddf651b.browserify
26 11 2018 14:48:48.784:DEBUG [framework.browserify]: add bundle to config.files at position 0
26 11 2018 14:48:48.791:DEBUG [web-server]: Instantiating middleware
26 11 2018 14:48:48.853:DEBUG [watcher]: Excluded file "/home/joe/karma/mobile-web-react/karma.conf.js"
26 11 2018 14:48:48.862:DEBUG [framework.browserify]: building bundle
26 11 2018 14:48:48.865:DEBUG [framework.browserify]: updating project.config.js in bundle
26 11 2018 14:48:48.865:DEBUG [framework.browserify]: updating test.js in bundle
26 11 2018 14:48:49.570:DEBUG [framework.browserify]: bundling
26 11 2018 14:48:49.661:INFO [framework.browserify]: bundle built
26 11 2018 14:48:49.663:INFO [karma-server]: Karma v3.1.1 server started at http://0.0.0.0:9876/
26 11 2018 14:48:49.667:INFO [launcher]: Launching browsers PhantomJS with concurrency unlimited
26 11 2018 14:48:49.680:INFO [launcher]: Starting browser PhantomJS
26 11 2018 14:48:49.681:DEBUG [temp-dir]: Creating temp dir at /tmp/karma-86591091
26 11 2018 14:48:49.683:DEBUG [launcher]: /usr/local/lib/node_modules/phantomjs/lib/phantom/bin/phantomjs /tmp/karma-86591091/capture.js
26 11 2018 14:48:49.834:DEBUG [web-server]: serving: /usr/local/lib/node_modules/karma/static/client.html
26 11 2018 14:48:49.863:DEBUG [web-server]: serving: /usr/local/lib/node_modules/karma/static/karma.js
26 11 2018 14:48:49.923:DEBUG [karma-server]: A browser has connected on socket bYWR4pruFDshDCE9AAAA
26 11 2018 14:48:49.978:DEBUG [web-server]: upgrade /socket.io/?EIO=3&transport=websocket&sid=bYWR4pruFDshDCE9AAAA
26 11 2018 14:48:50.022:INFO [PhantomJS 2.1.1 (Linux 0.0.0)]: Connected on socket bYWR4pruFDshDCE9AAAA with id 86591091
26 11 2018 14:48:50.031:DEBUG [launcher]: PhantomJS (id 86591091) captured in 0.364 secs
26 11 2018 14:48:50.047:DEBUG [phantomjs.launcher]:
26 11 2018 14:48:50.051:DEBUG [middleware:karma]: custom files null null null
26 11 2018 14:48:50.051:DEBUG [middleware:karma]: Serving static request /context.html
26 11 2018 14:48:50.051:DEBUG [web-server]: serving: /usr/local/lib/node_modules/karma/static/context.html
26 11 2018 14:48:50.054:WARN [middleware:karma]: Invalid file type, defaulting to js. browserify
26 11 2018 14:48:50.064:DEBUG [middleware:source-files]: Requesting /absolute/usr/local/lib/node_modules/karma-jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?1f336da4025323945fc818c69bdc564a85081e4e
26 11 2018 14:48:50.064:DEBUG [middleware:source-files]: Fetching /usr/local/lib/node_modules/karma-jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js
26 11 2018 14:48:50.065:DEBUG [web-server]: serving (cached): /usr/local/lib/node_modules/karma-jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js
26 11 2018 14:48:50.088:DEBUG [middleware:source-files]: Requesting /base/test.js?f1e8afc0445d448008af53b945365a082c4f2f4d
26 11 2018 14:48:50.088:DEBUG [middleware:source-files]: Fetching /home/joe/karma/mobile-web-react/test.js
26 11 2018 14:48:50.089:DEBUG [middleware:source-files]: Requesting /base/project.config.js?5ec2aa573f32095500773291513ae6910e25a090
26 11 2018 14:48:50.089:DEBUG [middleware:source-files]: Fetching /home/joe/karma/mobile-web-react/project.config.js
26 11 2018 14:48:50.089:DEBUG [middleware:source-files]: Requesting /absolute/tmp/1830825872ce6d6f085118f36ddf651b.browserify?0d315cdf3617983b1178913f6058fe7a63276fd1
26 11 2018 14:48:50.089:DEBUG [middleware:source-files]: Fetching /tmp/1830825872ce6d6f085118f36ddf651b.browserify
26 11 2018 14:48:50.089:DEBUG [middleware:source-files]: Requesting /absolute/usr/local/lib/node_modules/karma-jasmine/lib/boot.js?945a38bf4e45ad2770eb94868231905a04a0bd3e
26 11 2018 14:48:50.089:DEBUG [middleware:source-files]: Fetching /usr/local/lib/node_modules/karma-jasmine/lib/boot.js
26 11 2018 14:48:50.090:DEBUG [middleware:source-files]: Requesting /absolute/usr/local/lib/node_modules/karma-jasmine/lib/adapter.js?3098011cfe00faa2a869a8cffce13f3befc1a035
26 11 2018 14:48:50.090:DEBUG [middleware:source-files]: Fetching /usr/local/lib/node_modules/karma-jasmine/lib/adapter.js
26 11 2018 14:48:50.090:DEBUG [web-server]: serving (cached): /home/joe/karma/mobile-web-react/test.js
26 11 2018 14:48:50.091:DEBUG [web-server]: serving (cached): /home/joe/karma/mobile-web-react/project.config.js
26 11 2018 14:48:50.091:DEBUG [web-server]: serving (cached): /tmp/1830825872ce6d6f085118f36ddf651b.browserify
26 11 2018 14:48:50.093:DEBUG [web-server]: serving (cached): /usr/local/lib/node_modules/karma-jasmine/lib/boot.js
26 11 2018 14:48:50.094:DEBUG [web-server]: serving (cached): /usr/local/lib/node_modules/karma-jasmine/lib/adapter.js
26 11 2018 14:48:50.096:DEBUG [web-server]: serving: /usr/local/lib/node_modules/karma/static/context.js
PhantomJS 2.1.1 (Linux 0.0.0): Executed 1 of 1 SUCCESS (0.013 secs / 0.001 secs)
TOTAL: 1 SUCCESS
26 11 2018 14:48:50.144:DEBUG [karma-server]: Run complete, exiting.
26 11 2018 14:48:50.145:DEBUG [launcher]: Disconnecting all browsers
26 11 2018 14:48:50.146:DEBUG [framework.browserify]: cleaning up
26 11 2018 14:48:50.156:DEBUG [launcher]: Process PhantomJS exited with code null
26 11 2018 14:48:50.156:DEBUG [temp-dir]: Cleaning temp dir /tmp/karma-86591091
26 11 2018 14:48:50.162:DEBUG [launcher]: Finished all browsers |
Sample Test Code(test.js)
describe('ChromeLauncher', function () {
it('works', function () {
expect(2).toBe(2);
})
}) |
Trouble Shooting
ReferenceError: Can't find variable: process
ReferenceError: Can't find variable: process
karam.conf.js
frameworks: ['browserify','jasmine'],
preprocessors: {
'*.js': ['browserify']
},
|
browserify cannot find npm module
npm install -g browserify |
'QA > Test Automation' 카테고리의 다른 글
| MAC에서 Appinum 설치하기 (0) | 2021.01.25 |
|---|---|
| 구글 스토어&앱 스토어에서 메타데이터 긁어오고싶을 경우 (1) | 2019.04.29 |
| [Test Framework] katalon (0) | 2018.03.13 |
| postman integration with jenkins (0) | 2017.08.11 |
| Appinum에서 한글(non ASCII) 입력 해결 방안 (0) | 2017.06.09 |
댓글