{"id":16387199,"url":"https://github.com/zackshen/js-test-with-karma","last_synced_at":"2026-03-18T19:19:32.470Z","repository":{"id":9825721,"uuid":"11811875","full_name":"zackshen/js-test-with-karma","owner":"zackshen","description":"it's a demo project intergrated with karma for testing js ","archived":false,"fork":false,"pushed_at":"2016-10-31T04:20:06.000Z","size":867,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-22T12:15:01.445Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zackshen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-08-01T08:30:48.000Z","updated_at":"2023-03-05T00:48:26.000Z","dependencies_parsed_at":"2022-09-14T15:32:12.480Z","dependency_job_id":null,"html_url":"https://github.com/zackshen/js-test-with-karma","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zackshen/js-test-with-karma","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackshen%2Fjs-test-with-karma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackshen%2Fjs-test-with-karma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackshen%2Fjs-test-with-karma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackshen%2Fjs-test-with-karma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zackshen","download_url":"https://codeload.github.com/zackshen/js-test-with-karma/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackshen%2Fjs-test-with-karma/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29980774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T16:35:47.903Z","status":"ssl_error","status_checked_at":"2026-03-01T16:35:44.899Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T04:25:34.665Z","updated_at":"2026-03-01T19:01:26.996Z","avatar_url":"https://github.com/zackshen.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Install Guide\r\n\r\n## 1. node\r\n\r\n\u003c/br\u003e\r\n### 1. get node\r\n\twget -c http://nodejs.org/dist/v0.10.15/node-v0.10.15-linux-x64.tar.gz\r\n\r\n\u003c/br\u003e\r\n### 2. uncompress\r\n\ttar -zxvf node-v0.10.15-linux-x64.tar.gz -C /usr/local/\r\n\r\n\u003c/br\u003e\r\n### 3. export to env\r\n\texport PATH=$PATH:/usr/local/node/bin/\r\n\r\n\u003c/br\u003e\r\n\u003c/br\u003e\r\n## 3. phantomjs\r\n\u003c/br\u003e\r\n### 1. get phantomjs\r\n\twget -c https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2\r\n\u003c/br\u003e\r\n###\t2. install\r\n\tbunzip2 phantomjs-1.9.1-linux-x86_64.tar.bz2 \u0026\u0026 tar xvf phantomjs-1.9.1-linux-x86_64.tar -C /usr/local/\r\n\u003c/br\u003e\r\n###\t3. export PHANTOMJS_BIN\r\n\texport PHANTOMJS_BIN=/usr/local/phantomjs/bin/phantomjs\r\n\r\n\u003c/br\u003e\r\n## 2. karma\r\n\u003c/br\u003e\r\n### Global installation\r\n\tnpm install -g karma\r\n\u003c/br\u003e\r\n### Local installation\r\n\tnpm install karma\r\n\r\n\u003c/br\u003e\r\n\u003c/br\u003e\r\n# How to run\r\n\u003c/br\u003e\r\n##\t1. Generate config with karma\r\n\tcd project-with-js-test/config \u0026\u0026 karma init\r\n\r\n\u003c/br\u003e\r\n###\t2. Step by Step choose\r\n\r\n\u003c/br\u003e\r\n### 3. Manually config karma.conf.js\r\n* I put a sample config in the folder, you can copy it as karma.conf.js\r\n\r\n\u003c/br\u003e\r\n### 4. Run test\r\nthere are some sample test code in the unit folder, run it directly.\r\nafter test finished, the test result would be found in the result folder.\r\n\r\n\t# karma start config/karma.conf.js\r\n\r\n\tINFO [karma]: Karma server started at http://localhost:9876/\r\n\tINFO [launcher]: Starting browser PhantomJS\r\n\tINFO [PhantomJS 1.9 (Linux)]: Connected on socket id NWw9paZdn_1nAT5P6eV2\r\n\t PhantomJS 1.9 (Linux): Executed 2 of 2 SUCCESS (0.087 secs / 0.002 secs)\r\n\t.\r\n\tPhantomJS 1.9 (Linux): Executed 2 of 2 SUCCESS (0.087 secs / 0.002 secs)\r\n\r\n# How to Run with fixtures\r\n## Project directory\r\n    test_js_with_karma\r\n    ├── config\r\n    │   ├── karma.conf.js\r\n    │   └── karma.conf.js.sample\r\n    ├── fixtures\r\n    │   ├── html\r\n    │   │   └── sample_component.html\r\n    │   └── json\r\n    │       └── sample_map.json\r\n    ├── js\r\n    │   └── utils.js\r\n    ├── lib\r\n    │   ├── jasmine-jquery.js\r\n    │   └── jquery-1.7.1.min.js\r\n    ├── README.md\r\n    ├── results\r\n    │   └── test-results.xml\r\n    ├── test.sh\r\n    └── units\r\n        └── utilSpec.js\r\n\r\n\u003cbr/\u003e\r\n## JSON example\r\n### 1. add fixtures files in karma.conf.js\r\n      {\r\n          pattern: '../fixtures/json/*.json',\r\n          watched: true,\r\n          included: false,\r\n          served: true\r\n      }\r\n\r\n### 2. add proxy config into karma.conf.js\r\n    proxies = {\r\n        '/': 'http://localhost:3000/'\r\n    }\r\n\r\n### 3. need to start a file proxy server, here i use python SimpleHTTPServer\r\n    python -m SimpleHTTPServer 3000\r\n\r\n### 4. start test\r\n    karma start config/karma.conf.js\r\n\r\n    Serving HTTP on 0.0.0.0 port 3000 ...\r\n    [2013-08-02 17:44:04.569] [WARN] config - \"/\" is proxied, you should probably change urlRoot to avoid conflicts\r\n    INFO [karma]: Karma server started at http://localhost:9876/\r\n    INFO [launcher]: Starting browser PhantomJS\r\n    INFO [PhantomJS 1.9 (Linux)]: Connected on socket id MuFBJ0E_6vnPptwvaaD9\r\n    localhost - - [02/Aug/2013 17:44:05] \"GET /fixtures/json/sample_map.json?_=1375436645848 HTTP/1.1\" 200 -\r\n    localhost - - [02/Aug/2013 17:44:05] \"GET /fixtures/json/sample_map.json?_=1375436645865 HTTP/1.1\" 200 -\r\n    localhost - - [02/Aug/2013 17:44:05] \"GET /fixtures/json/sample_map.json?_=1375436645876 HTTP/1.1\" 200 -\r\n    PhantomJS 1.9 (Linux): Executed 5 of 5 SUCCESS (0.115 secs / 0.051 secs)\r\n    .\r\n    PhantomJS 1.9 (Linux): Executed 5 of 5 SUCCESS (0.115 secs / 0.051 secs)\r\n\r\nhere i provide a test.sh to start test simplely.\r\n\u003cbr/\u003e\r\n## HTML example\r\n### 1. add fixtures files in karma.conf.js\r\n      {\r\n          pattern: '../fixtures/html/*.html',\r\n          watched: true,\r\n          included: false,\r\n          served: true\r\n      }\r\n\r\n### 2. add proxy config into karma.conf.js\r\n    proxies = {\r\n        '/': 'http://localhost:3000/'\r\n    }\r\n\r\n### 3. need to start a file proxy server, here i use python SimpleHTTPServer\r\n    python -m SimpleHTTPServer 3000\r\n\r\n### 4. start test\r\n\r\n    karma start config/karma.conf.js\r\n\r\n    Serving HTTP on 0.0.0.0 port 3000 ...\r\n    [2013-08-05 10:25:02.357] [WARN] config - \"/\" is proxied, you should probably change urlRoot to avoid conflicts\r\n    INFO [karma]: Karma server started at http://localhost:9876/\r\n    INFO [launcher]: Starting browser PhantomJS\r\n    INFO [PhantomJS 1.9 (Linux)]: Connected on socket id ivnU9F8dlKMP9_6ISsGw\r\n    localhost - - [05/Aug/2013 10:25:03] \"GET /fixtures/json/sample_map.json?_=1375669503146 HTTP/1.1\" 200 -\r\n    localhost - - [05/Aug/2013 10:25:03] \"GET /fixtures/json/sample_map.json?_=1375669503157 HTTP/1.1\" 200 -\r\n    localhost - - [05/Aug/2013 10:25:03] \"GET /fixtures/json/sample_map.json?_=1375669503163 HTTP/1.1\" 200 -\r\n    localhost - - [05/Aug/2013 10:25:03] \"GET /fixtures/html/sample_component.html?1375669503167 HTTP/1.1\" 200 -\r\n    PhantomJS 1.9 (Linux): Executed 8 of 8 SUCCESS (0.079 secs / 0.038 secs)\r\n    .\r\n    PhantomJS 1.9 (Linux): Executed 8 of 8 SUCCESS (0.079 secs / 0.038 secs)\r\n\r\n\r\n# Code Coverage\r\n## Install Istanbul\r\n    npm install -g istanbul\r\n\r\n## Config karma with coverage feature\r\n    preprocessors = {\r\n        '**/js/*.js': 'coverage'\r\n    };\r\n\r\n    reporters = [..., 'converage']\r\n\r\n    coverageReporter = {\r\n        type : 'html',\r\n        dir : '../coverage/',\r\n        file : 'coverage.html'\r\n    }\r\n\r\n## Test Result, new Project Tree\r\n    .\r\n    ├── config\r\n    │   └── karma.conf.js\r\n    ├── **coverage**\r\n    │   ├── coverage-PhantomJS 1.9 (Linux)-20130805_110320.json\r\n    │   └── PhantomJS 1.9 (Linux)\r\n    │       ├── index.html\r\n    │       ├── js\r\n    │       │   ├── **index.html**\r\n    │       │   └── **utils.js.html**\r\n    │       ├── prettify.css\r\n    │       └── prettify.js\r\n    ├── fixtures\r\n    │   ├── html\r\n    │   │   └── sample_component.html\r\n    │   └── json\r\n    │       └── sample_map.json\r\n    ├── js\r\n    │   └── utils.js\r\n    ├── lib\r\n    │   ├── jasmine-jquery.js\r\n    │   └── jquery-1.7.1.min.js\r\n    ├── README.md\r\n    ├── results\r\n    │   └── test-results.xml\r\n    ├── test.sh\r\n    └── units\r\n        └── utilSpec.js\r\n\r\n# With Jenkins\r\n![Image](../master/snapshots/jenkins_1.jpg?raw=true)\r\n![Image](../master/snapshots/jenkins_2.jpg?raw=true)\r\n![Image](../master/snapshots/jenkins_3.jpg?raw=true)\r\n![Image](../master/snapshots/jenkins_4.jpg?raw=true)\r\n![Image](../master/snapshots/jenkins_5.jpg?raw=true)\r\n\r\n\r\n# References\r\n\r\n+ [Node](http://nodejs.org/)\r\n+ [Karma](http://karma-runner.github.io/0.8/index.html)\r\n+ [PhantomJS](http://phantomjs.org/)\r\n+ [JQuery](http://jquery.com/)\r\n+ [Jasmine](http://jasmine.github.io/)\r\n+ [Jasmine-JQuery](https://github.com/velesin/jasmine-jquery)\r\n+ [Istanbul](https://github.com/yahoo/istanbul)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzackshen%2Fjs-test-with-karma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzackshen%2Fjs-test-with-karma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzackshen%2Fjs-test-with-karma/lists"}