├── src ├── adapter.wrapper └── adapter.js ├── .travis.yml ├── scripts ├── refresh.js └── build.js ├── karma.conf.js ├── lib └── index.js ├── .gitignore ├── test └── adapter.spec.js ├── LICENSE ├── package.json ├── README.md └── CHANGELOG.md /src/adapter.wrapper: -------------------------------------------------------------------------------- 1 | ;(function (window) { 2 | 3 | %CONTENT% 4 | 5 | window.assert = window.assert.customize(createConfigObject(window.__karma__)) 6 | })(window) 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | before_script: 2 | - export DISPLAY=:99.0 3 | - sh -e /etc/init.d/xvfb start 4 | 5 | script: 6 | - "npm test" 7 | 8 | language: node_js 9 | 10 | node_js: 11 | - "7" 12 | - "6" 13 | 14 | sudo: false 15 | -------------------------------------------------------------------------------- /src/adapter.js: -------------------------------------------------------------------------------- 1 | // Default configuration 2 | var assertConfig = {} 3 | // Pass options from client.assert to power-assert 4 | /* eslint-disable no-unused-vars */ 5 | var createConfigObject = function (karma) { 6 | if (!karma.config || !karma.config.assert) { 7 | return assertConfig 8 | } 9 | 10 | // Copy all properties to assertConfig 11 | for (var key in karma.config.assert) { 12 | assertConfig[key] = karma.config.assert[key] 13 | } 14 | 15 | return assertConfig 16 | } 17 | -------------------------------------------------------------------------------- /scripts/refresh.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var rimraf = require('rimraf') 3 | var target = getTargetPath() 4 | 5 | function getTargetPath () { 6 | var index = '' 7 | var target = '' 8 | 9 | try { 10 | index = require.resolve('karma-power-assert') 11 | target = path.resolve(index, '../../') 12 | } catch (e) { 13 | target = '' 14 | } 15 | 16 | return target 17 | } 18 | 19 | try { 20 | if (target) rimraf.sync(target) 21 | } catch (e) { 22 | console.error(e) 23 | } 24 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | module.exports = function (config) { 2 | config.set({ 3 | frameworks: ['mocha', 'power-assert'], 4 | 5 | files: [ 6 | 'test/*.js' 7 | ], 8 | 9 | client: { 10 | assert: { 11 | output: { 12 | maxDepth: 2 13 | } 14 | } 15 | }, 16 | 17 | preprocessors: { 18 | 'test/**/*.spec.js': ['espower'] 19 | }, 20 | 21 | browsers: process.env.TRAVIS ? ['Firefox'] : ['Chrome'], 22 | 23 | singleRun: true 24 | }) 25 | } 26 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | 3 | var createPattern = function (path) { 4 | return {pattern: path, included: true, served: true, watched: false} 5 | } 6 | 7 | var initPowerAssert = function (files) { 8 | files.unshift(createPattern(path.join(__dirname, 'adapter.js'))) 9 | files.unshift(createPattern(path.resolve(require.resolve('power-assert'), '../build/power-assert.js'))) 10 | } 11 | 12 | initPowerAssert.$inject = ['config.files', 'config.client.assert'] 13 | 14 | module.exports = { 15 | 'framework:power-assert': ['factory', initPowerAssert] 16 | } 17 | -------------------------------------------------------------------------------- /scripts/build.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs') 2 | var path = require('path') 3 | var files = { 4 | src: path.resolve(__dirname, '../src/adapter.js'), 5 | content: path.resolve(__dirname, '../src/adapter.wrapper'), 6 | out: path.resolve(__dirname, '../lib/adapter.js') 7 | } 8 | var src = fs.readFileSync(files.src, 'utf8') 9 | var content = fs.readFileSync(files.content, 'utf8') 10 | var wrappers = content.split(/%CONTENT%\r?\n/) 11 | var wrapper = wrappers[0] + src + wrappers[1] 12 | 13 | try { 14 | fs.writeFileSync(files.out, wrapper) 15 | } catch (e) { 16 | console.error(e) 17 | } 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 18 | .grunt 19 | 20 | # node-waf configuration 21 | .lock-wscript 22 | 23 | # Compiled binary addons (http://nodejs.org/api/addons.html) 24 | build/Release 25 | 26 | # Dependency directory 27 | node_modules 28 | 29 | # Optional npm cache directory 30 | .npm 31 | 32 | # Optional REPL history 33 | .node_repl_history 34 | 35 | # karma-power-assert 36 | lib/adapter.js 37 | -------------------------------------------------------------------------------- /test/adapter.spec.js: -------------------------------------------------------------------------------- 1 | describe('client.assert', function() { 2 | var orininalAssert = assert; 3 | 4 | describe('.output.maxDepth', function () { 5 | beforeEach('put fixtures', function () { 6 | this.foo = {flag: true}; 7 | this.bar = {} 8 | }) 9 | 10 | afterEach(function () { 11 | assert = orininalAssert; 12 | }) 13 | 14 | it('should be 2 as the customized value in karma.conf.js', function () { 15 | var expected = [this.foo] 16 | var actual = [this.bar] 17 | try { 18 | assert.deepEqual(expected, actual) 19 | } catch (e) { 20 | var error = e.message 21 | var message = [ 22 | ' # adapter.spec.js:18', 23 | ' ', 24 | ' assert.deepEqual(expected, actual)', 25 | ' | | ', 26 | ' | [Object{}]', 27 | ' [Object{flag:true}]', 28 | '' 29 | ].join('\n') + ' ' 30 | assert.deepEqual(error, message) 31 | } 32 | }) 33 | }) 34 | }) 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Daijiro Wachi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "karma-power-assert", 3 | "version": "1.0.0", 4 | "description": "A Karma plugin. Adapter for power-assert assertion library.", 5 | "main": "lib/index.js", 6 | "files": [ 7 | "lib" 8 | ], 9 | "scripts": { 10 | "pretest": "npm run build", 11 | "test": "npm run lint && karma start", 12 | "build": "npm run scripts", 13 | "postbuild": "npm install --progress=false", 14 | "prerelease": "npm test", 15 | "release": "standard-version", 16 | "lint": "standard src/*.js lib/index.js scripts/*.js", 17 | "scripts": "node scripts/refresh.js && node scripts/build.js" 18 | }, 19 | "repository": "power-assert-js/karma-power-assert", 20 | "keywords": [ 21 | "karma", 22 | "karma-plugin", 23 | "karma-adapter", 24 | "power-assert" 25 | ], 26 | "author": "Daijiro Wachi ", 27 | "dependencies": {}, 28 | "devDependencies": { 29 | "karma": "1.x || ^0.13.15", 30 | "karma-chrome-launcher": "2.0.0", 31 | "karma-espower-preprocessor": "^1.1.0", 32 | "karma-firefox-launcher": "1.x || ~0.1.0", 33 | "karma-mocha": "^1.1.1", 34 | "karma-power-assert": ".", 35 | "mocha": "^3.1.1", 36 | "power-assert": "^1.4.2", 37 | "rimraf": "^2.5.4", 38 | "standard": "^10.0.1", 39 | "standard-version": "^4.0.0", 40 | "uglify-js": "^2.7.0" 41 | }, 42 | "peerDependencies": { 43 | "power-assert": "^1.5.0" 44 | }, 45 | "bugs": { 46 | "url": "https://github.com/power-assert-js/karma-power-assert/issues" 47 | }, 48 | "homepage": "https://github.com/power-assert-js/karma-power-assert#readme", 49 | "license": "MIT" 50 | } 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # karma-power-assert 2 | 3 | [![npm version](https://img.shields.io/npm/v/karma-power-assert.svg?style=flat-square)](https://www.npmjs.com/package/karma-power-assert) [![npm downloads](https://img.shields.io/npm/dm/karma-power-assert.svg?style=flat-square)](https://www.npmjs.com/package/karma-power-assert) 4 | 5 | [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/power-assert-js/karma-power-assert) [![Standard Version](https://img.shields.io/badge/release-standard%20version-brightgreen.svg?style=flat-square)](https://github.com/power-assert-js/karma-power-assert) 6 | 7 | [![Build Status](https://img.shields.io/travis/power-assert-js/karma-power-assert/master.svg?style=flat-square)](https://travis-ci.org/power-assert-js/karma-power-assert) [![Dependency Status](https://img.shields.io/david/power-assert-js/karma-power-assert.svg?style=flat-square)](https://david-dm.org/power-assert-js/karma-power-assert) [![devDependency Status](https://img.shields.io/david/dev/power-assert-js/karma-power-assert.svg?style=flat-square)](https://david-dm.org/power-assert-js/karma-power-assert#info=devDependencies) 8 | 9 | > Adapter for [power-assert](https://github.com/power-assert-js/power-assert) assertion library. 10 | 11 | ## Installation 12 | via npm 13 | ```bash 14 | $ npm install karma-power-assert --save-dev 15 | ``` 16 | 17 | Instructions on how to install `karma` can be found [here.](http://karma-runner.github.io/0.12/intro/installation.html) 18 | 19 | 20 | ## Configuration 21 | Following code shows the default configuration... 22 | ```js 23 | // karma.conf.js 24 | module.exports = function(config) { 25 | config.set({ 26 | frameworks: ['mocha', 'power-assert'], 27 | 28 | files: [ 29 | '*.js' 30 | ], 31 | 32 | preprocessors: { 33 | 'test/**/*.spec.js': ['espower'] 34 | } 35 | }); 36 | }; 37 | ``` 38 | 39 | If you want to pass configuration options directly to `assert.customize` you can 40 | do this in the following way 41 | 42 | ```js 43 | // karma.conf.js 44 | module.exports = function(config) { 45 | config.set({ 46 | frameworks: ['mocha', 'power-assert'], 47 | 48 | files: [ 49 | '*.js' 50 | ], 51 | 52 | preprocessors: { 53 | 'test/**/*.spec.js': ['espower'] 54 | }, 55 | 56 | client: { 57 | assert: { 58 | output: { 59 | maxDepth: 2 60 | } 61 | } 62 | } 63 | }); 64 | }; 65 | ``` 66 | 67 | ---- 68 | 69 | For more information on Karma see the [homepage]. 70 | 71 | 72 | [homepage]: http://karma-runner.github.com 73 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 4 | 5 | 6 | # [1.0.0](https://github.com/power-assert-js/karma-power-assert/compare/v0.0.5...v1.0.0) (2017-01-09) 7 | 8 | 9 | ### Bug Fixes 10 | 11 | * **package.json:** replace the old org name with new one ([9f6aebf](https://github.com/power-assert-js/karma-power-assert/commit/9f6aebf)) 12 | 13 | 14 | 15 | 16 | ## 0.0.5 (2017-01-05) 17 | 18 | 19 | ### Bug Fixes 20 | 21 | * **deps:** fix error on ci ([dce561d](https://github.com/watilde/karma-power-assert/commit/dce561d)) 22 | * **npm script:** rename prepublish to prerelease ([8757950](https://github.com/watilde/karma-power-assert/commit/8757950)) 23 | * **npm-script:** add prepublish script ([ce0abd8](https://github.com/watilde/karma-power-assert/commit/ce0abd8)) 24 | * **readme:** add espower to example codes ([e7fb30e](https://github.com/watilde/karma-power-assert/commit/e7fb30e)) 25 | * **readme:** add standard-version badge ([f3a0c40](https://github.com/watilde/karma-power-assert/commit/f3a0c40)) 26 | * **travis:** add before_scripts to launch firefox ([a0d8693](https://github.com/watilde/karma-power-assert/commit/a0d8693)) 27 | * **travis:** drop v0.12 and iojs ([0460515](https://github.com/watilde/karma-power-assert/commit/0460515)) 28 | 29 | 30 | 31 | 32 | ## [0.0.4](https://github.com/watilde/karma-power-assert/compare/v0.0.3...v0.0.4) (2016-08-01) 33 | 34 | ### Bug Fixes 35 | 36 | * **deps:** update `karma-mocha`, `rimraf`, `standard`, `standard-version` and `uglify-js` ([8cfd3af](https://github.com/watilde/karma-power-assert/commit/8cfd3af)) 37 | 38 | * **deps:** update `mocha` ([64aa9b](https://github.com/watilde/karma-power-assert/commit/64aa9b)) 39 | 40 | 41 | ## [0.0.3](https://github.com/watilde/karma-power-assert/compare/v0.0.2...v0.0.3) (2016-05-14) 42 | 43 | 44 | ### Bug Fixes 45 | 46 | * **readme:** add espower to example codes ([e7fb30e](https://github.com/watilde/karma-power-assert/commit/e7fb30e)) 47 | 48 | 49 | 50 | 51 | ## [0.0.2](https://github.com/watilde/karma-power-assert/compare/v0.0.1...v0.0.2) (2016-05-14) 52 | 53 | 54 | ### Bug Fixes 55 | 56 | * **deps:** fix error on ci ([dce561d](https://github.com/watilde/karma-power-assert/commit/dce561d)) 57 | * **npm script:** rename prepublish to prerelease ([8757950](https://github.com/watilde/karma-power-assert/commit/8757950)) 58 | * **npm-script:** add prepublish script ([ce0abd8](https://github.com/watilde/karma-power-assert/commit/ce0abd8)) 59 | * **readme:** add standard-version badge ([f3a0c40](https://github.com/watilde/karma-power-assert/commit/f3a0c40)) 60 | * **travis:** add before_scripts to launch firefox ([a0d8693](https://github.com/watilde/karma-power-assert/commit/a0d8693)) 61 | 62 | 63 | 64 | 65 | ## 0.0.1 (2016-05-14) 66 | first release 67 | --------------------------------------------------------------------------------