[
  {
    "path": ".eslintrc",
    "content": "{\n  \"extends\": \"standard\"\n}"
  },
  {
    "path": ".gitignore",
    "content": "lib/adapter.js\nnode_modules\nnpm-debug.log\n.idea\n"
  },
  {
    "path": ".mailmap",
    "content": "<bitwiseman@gmail.com> <lnewman@book.com>\n<vojta.jina@gmail.com> <vojta@google.com>\n<friedel.ziegelmayer@gmail.com> <dignifiedquire@gmail.com>\n"
  },
  {
    "path": ".npmignore",
    "content": ".gitignore\n.travis.yml\nsrc\ntest\ntasks\n\nGruntfile.coffee\nkarma.conf.js\nkarma-v0.8.conf.js\nCONTRIBUTING.md\n"
  },
  {
    "path": ".travis.yml",
    "content": "sudo: false\nlanguage: node_js\nnode_js:\n  - 10\n  - 12\n\nservices:\n  - xvfb\n\nbefore_install:\n  - npm install -g npm\n\nbefore_script:\n  - npm install -g grunt-cli\n  - echo \"TRAVIS_COMMIT $TRAVIS_COMMIT\"\n  - echo \"TRAVIS_PULL_REQUEST_SHA $TRAVIS_PULL_REQUEST_SHA\"\n  - COMMIT_TO_VALIDATE=${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT}\n  - echo \"COMMIT_TO_VALIDATE $COMMIT_TO_VALIDATE\"\n  - 'if [ \"$VALIDATE_COMMIT_MSG\" == \"true\" ]; then ./scripts/validate-commit-msg.sh $COMMIT_TO_VALIDATE; fi'\n\nscript:\n  - npm run test:lib\n  - grunt\n\nafter_success:\n  # run automated release process with semantic-release\n  - echo \"TRAVIS_BRANCH=$TRAVIS_BRANCH, TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE, TRAVIS_NODE_VERSION=$TRAVIS_NODE_VERSION\"\n  - if [[ \"$TRAVIS_BRANCH\" == \"master\" && \"$TRAVIS_EVENT_TYPE\" == \"push\" && \"$TRAVIS_NODE_VERSION\" == \"12\" ]]; then\n      semantic-release;\n    fi;"
  },
  {
    "path": "CHANGELOG.md",
    "content": "## [2.0.1](https://github.com/karma-runner/karma-mocha/compare/v2.0.0...v2.0.1) (2020-04-29)\n\n\n### Bug Fixes\n\n* **deps:** Report fails without emit 'test end' event ([#223](https://github.com/karma-runner/karma-mocha/issues/223)) ([1a8226c](https://github.com/karma-runner/karma-mocha/commit/1a8226c915350fd2e203fb60084642cb14aef498))\n\n# [2.0.0](https://github.com/karma-runner/karma-mocha/compare/v1.3.0...v2.0.0) (2020-04-14)\n\n\n### Features\n\n* **ci:** enable semanitic-release ([5a5b6d5](https://github.com/karma-runner/karma-mocha/commit/5a5b6d52399eab9a20592e3536b3e2df1b3ce9ce))\n* Expose 'pending' status ([e847121](https://github.com/karma-runner/karma-mocha/commit/e847121e35f59a498c3b09f87f138621b550629b)), closes [#109](https://github.com/karma-runner/karma-mocha/issues/109)\n\n\n* Update Node.js versions ([fd64f5b](https://github.com/karma-runner/karma-mocha/commit/fd64f5bcacf2e0de6eeb24772384442bd6a37bed))\n\n\n### BREAKING CHANGES\n\n* drop support for node 8\n\n<a name=\"1.3.0\"></a>\n# [1.3.0](https://github.com/karma-runner/karma-mocha/compare/v1.2.0...v1.3.0) (2016-11-09)\n\n\n### Bug Fixes\n\n* polyfill Date.now to restore IE compat ([246f25a](https://github.com/karma-runner/karma-mocha/commit/246f25a))\n* **deps:** remove peer dependency on mocha ([0bbf932](https://github.com/karma-runner/karma-mocha/commit/0bbf932)), closes [#114](https://github.com/karma-runner/karma-mocha/issues/114)\n\n\n### Features\n\n* support mocha opts ([11a0dd8](https://github.com/karma-runner/karma-mocha/commit/11a0dd8)), closes [#99](https://github.com/karma-runner/karma-mocha/issues/99)\n\n\n\n<a name=\"1.2.0\"></a>\n# [1.2.0](https://github.com/karma-runner/karma-mocha/compare/v1.1.1...v1.2.0) (2016-09-26)\n\n\n### Bug Fixes\n\n* \"remove mocha stack entries\" was too greedy ([c893d0a](https://github.com/karma-runner/karma-mocha/commit/c893d0a))\n\n\n### Features\n\n* **reporter:** add timestamps to results ([7b41f52](https://github.com/karma-runner/karma-mocha/commit/7b41f52))\n* **reporter:** expose mocha test properties ([e4eb5fd](https://github.com/karma-runner/karma-mocha/commit/e4eb5fd))\n\n\n\n<a name=\"1.1.1\"></a>\n## [1.1.1](https://github.com/karma-runner/karma-mocha/compare/v1.1.0...v1.1.1) (2016-06-26)\n\n\n### Bug Fixes\n\n* handle non existing mochaConfig ([dcb74a5](https://github.com/karma-runner/karma-mocha/commit/dcb74a5))\n\n\n\n<a name=\"1.1.0\"></a>\n# [1.1.0](https://github.com/karma-runner/karma-mocha/compare/v1.0.1...v1.1.0) (2016-06-26)\n\n\n### Features\n\n* allow requiring files via karma.conf.js ([f00d6b3](https://github.com/karma-runner/karma-mocha/commit/f00d6b3)), closes [#84](https://github.com/karma-runner/karma-mocha/issues/84)\n* **deps:** update dependencies ([fe04ebb](https://github.com/karma-runner/karma-mocha/commit/fe04ebb))\n\n\n\n<a name=\"1.0.1\"></a>\n## [1.0.1](https://github.com/karma-runner/karma-mocha/compare/v0.2.2...v1.0.1) (2016-05-02)\n\n\n### Bug Fixes\n\n* Do not lose stack trace at debug.html ([0b5a392](https://github.com/karma-runner/karma-mocha/commit/0b5a392))\n\n\n\n<a name=\"0.2.2\"></a>\n## [0.2.2](https://github.com/karma-runner/karma-mocha/compare/v0.2.1...v0.2.2) (2016-02-15)\n\n\n\n<a name=\"0.2.1\"></a>\n## [0.2.1](https://github.com/karma-runner/karma-mocha/compare/v0.2.0...v0.2.1) (2015-11-13)\n\n\n### Bug Fixes\n\n* Tests that call this.skip() are marked as failed instead of skipped fix [#77](https://github.com/karma-runner/karma-mocha/issues/77) ([73e554f](https://github.com/karma-runner/karma-mocha/commit/73e554f))\n\n\n\n<a name=\"0.2.0\"></a>\n# [0.2.0](https://github.com/karma-runner/karma-mocha/compare/v0.1.10...v0.2.0) (2015-06-22)\n\n\n### Bug Fixes\n\n* **config:** grep is interpreted as regexp ([01d11e6](https://github.com/karma-runner/karma-mocha/commit/01d11e6))\n* **npm:** Make .npmignore more sensible to dot files ([4ebf361](https://github.com/karma-runner/karma-mocha/commit/4ebf361)), closes [#59](https://github.com/karma-runner/karma-mocha/issues/59)\n* Drop karma as a peerDependency. ([5c11809](https://github.com/karma-runner/karma-mocha/commit/5c11809))\n\n\n\n<a name=\"0.1.10\"></a>\n## [0.1.10](https://github.com/karma-runner/karma-mocha/compare/v0.1.9...v0.1.10) (2014-12-04)\n\n\n\n<a name=\"0.1.9\"></a>\n## [0.1.9](https://github.com/karma-runner/karma-mocha/compare/v0.1.8...v0.1.9) (2014-08-23)\n\n\n### Bug Fixes\n\n* properly format err messages with new lines ([1144690](https://github.com/karma-runner/karma-mocha/commit/1144690)), closes [#40](https://github.com/karma-runner/karma-mocha/issues/40)\n\n\n\n<a name=\"0.1.8\"></a>\n## [0.1.8](https://github.com/karma-runner/karma-mocha/compare/v0.1.7...v0.1.8) (2014-08-18)\n\n\n### Bug Fixes\n\n* properly remove mocha stack entries ([b4ee7f2](https://github.com/karma-runner/karma-mocha/commit/b4ee7f2)), closes [#44](https://github.com/karma-runner/karma-mocha/issues/44) [#41](https://github.com/karma-runner/karma-mocha/issues/41)\n\n\n\n<a name=\"0.1.7\"></a>\n## [0.1.7](https://github.com/karma-runner/karma-mocha/compare/v0.1.6...v0.1.7) (2014-08-07)\n\n\n\n<a name=\"0.1.6\"></a>\n## [0.1.6](https://github.com/karma-runner/karma-mocha/compare/v0.1.5...v0.1.6) (2014-07-17)\n\n\n### Bug Fixes\n\n* correctly prepare the new version (v0.1.5) ([ab2a23f](https://github.com/karma-runner/karma-mocha/commit/ab2a23f))\n\n\n\n<a name=\"0.1.5\"></a>\n## [0.1.5](https://github.com/karma-runner/karma-mocha/compare/v0.1.4...v0.1.5) (2014-06-16)\n\n\n\n<a name=\"0.1.4\"></a>\n## [0.1.4](https://github.com/karma-runner/karma-mocha/compare/v0.1.3...v0.1.4) (2014-06-15)\n\n\n### Features\n\n* Allow define html reporter on debug page. resolve [#20](https://github.com/karma-runner/karma-mocha/issues/20) ([7f8d4cc](https://github.com/karma-runner/karma-mocha/commit/7f8d4cc))\n\n\n\n<a name=\"0.1.3\"></a>\n## [0.1.3](https://github.com/karma-runner/karma-mocha/compare/v0.1.2...v0.1.3) (2014-03-13)\n\n\n### Bug Fixes\n\n* grep for grunt-karma ([70aef65](https://github.com/karma-runner/karma-mocha/commit/70aef65))\n\n\n\n<a name=\"0.1.2\"></a>\n## [0.1.2](https://github.com/karma-runner/karma-mocha/compare/v0.1.1...v0.1.2) (2014-02-18)\n\n\n### Bug Fixes\n\n* restores the ability to use grep ([2787886](https://github.com/karma-runner/karma-mocha/commit/2787886))\n\n\n\n<a name=\"0.1.1\"></a>\n## [0.1.1](https://github.com/karma-runner/karma-mocha/compare/v0.1.0...v0.1.1) (2013-11-26)\n\n\n### Features\n\n* Pass client configuration to `mocha.setup method. ([4df9ba6](https://github.com/karma-runner/karma-mocha/commit/4df9ba6)), closes [#13](https://github.com/karma-runner/karma-mocha/issues/13)\n\n\n\n<a name=\"0.1.0\"></a>\n# [0.1.0](https://github.com/karma-runner/karma-mocha/compare/v0.0.4...v0.1.0) (2013-08-06)\n\n\n\n<a name=\"0.0.4\"></a>\n## [0.0.4](https://github.com/karma-runner/karma-mocha/compare/v0.0.3...v0.0.4) (2013-07-19)\n\n\n### Features\n\n* remove dump, as karma implements it ([e02af06](https://github.com/karma-runner/karma-mocha/commit/e02af06))\n\n\n\n<a name=\"0.0.3\"></a>\n## [0.0.3](https://github.com/karma-runner/karma-mocha/compare/v0.0.2...v0.0.3) (2013-07-07)\n\n\n### Bug Fixes\n\n* config does not have to be defined ([edfa534](https://github.com/karma-runner/karma-mocha/commit/edfa534))\n\n\n\n<a name=\"0.0.2\"></a>\n## [0.0.2](https://github.com/karma-runner/karma-mocha/compare/4f5470d...v0.0.2) (2013-07-05)\n\n\n### Bug Fixes\n\n* report time for skipped tests so that netTime is computed correctly ([4f5470d](https://github.com/karma-runner/karma-mocha/commit/4f5470d)), closes [#141](https://github.com/karma-runner/karma-mocha/issues/141)\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "Please see the [Contributing to Karma] guide for information on contributing to this project.\n\n[Contributing to Karma]: https://github.com/karma-runner/karma/blob/master/CONTRIBUTING.md\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License\n\nCopyright (C) 2011-2013 Google, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
  },
  {
    "path": "README.md",
    "content": "# karma-mocha\n\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/karma-runner/karma-mocha)\n [![npm version](https://img.shields.io/npm/v/karma-mocha.svg?style=flat-square)](https://www.npmjs.com/package/karma-mocha) [![npm downloads](https://img.shields.io/npm/dm/karma-mocha.svg?style=flat-square)](https://www.npmjs.com/package/karma-mocha)\n\n[![Build Status](https://img.shields.io/travis/karma-runner/karma-mocha/master.svg?style=flat-square)](https://travis-ci.org/karma-runner/karma-mocha) [![Dependency Status](https://img.shields.io/david/karma-runner/karma-mocha.svg?style=flat-square)](https://david-dm.org/karma-runner/karma-mocha) [![devDependency Status](https://img.shields.io/david/dev/karma-runner/karma-mocha.svg?style=flat-square)](https://david-dm.org/karma-runner/karma-mocha#info=devDependencies)\n\n> Adapter for the [Mocha](http://mochajs.org/) testing framework.\n\n## Installation\n\nInstall `karma-mocha` and `mocha` into to your project via `npm`:\n\n```shell\n$ npm install karma-mocha mocha --save-dev\n```\n\n`karma-mocha` should work with any version of `mocha`.\n\nSince `karma-mocha` is an adapter for [Karma](http://karma-runner.github.io), you likely have it installed already, but in case you don't:  \n\n```shell\n$ npm install karma --save-dev\n```\n\nIf you're having trouble, Karma provides [detailed instructions](http://karma-runner.github.io/1.0/intro/installation.html) on installation. \n\n## Configuration\nFollowing code shows the default configuration...\n```js\n// karma.conf.js\nmodule.exports = function(config) {\n  config.set({\n    frameworks: ['mocha'],\n\n    files: [\n      '*.js'\n    ]\n  });\n};\n```\n\nIf you want to pass configuration options directly to mocha you can\ndo this in the following way\n\n```js\n// karma.conf.js\nmodule.exports = function(config) {\n  config.set({\n    frameworks: ['mocha'],\n\n    files: [\n      '*.js'\n    ],\n\n    client: {\n      mocha: {\n        // change Karma's debug.html to the mocha web reporter\n        reporter: 'html',\n\n        // require specific files after Mocha is initialized\n        require: [require.resolve('bdd-lazy-var/bdd_lazy_var_global')],\n\n        // custom ui, defined in required file above\n        ui: 'bdd-lazy-var/global',\n      }\n    }\n  });\n};\n```\n\nIf you want run only some tests matching a given pattern you can\ndo this in the following way\n\n```sh\nkarma start &\nkarma run -- --grep=<pattern>\n```\n\nor\n\n```js\nmodule.exports = function(config) {\n  config.set({\n    ...\n    client: {\n      mocha: {\n        grep: '<pattern>', // passed directly to mocha\n        ...\n      }\n      ...\n    }\n  });\n};\n```\n\nIf you want to expose test properties specific to `mocha`, you can use the `expose` option:\n\n```js\nmodule.exports = function(config) {\n  config.set({\n    ...\n    client: {\n      mocha: {\n        expose: ['body'] // This will be exposed in a reporter as `result.mocha.body`\n        ...\n      }\n      ...\n    }\n  });\n};\n```\n\nIf you already have a configuration for Mocha in an opts file, you can use the `opts` option:\n\n```js\nmodule.exports = function(config) {\n  config.set({\n    ...\n    client: {\n      mocha: {\n        opts: 'test/mocha.opts' // You can set opts to equal true then plugin will load opts from default location 'test/mocha.opts'\n        ...\n      }\n      ...\n    }\n  });\n};\n```\n\n## Internals\n\nOn the end of each test `karma-mocha` passes to `karma` result object with fields:\n\n* `description` Test title.\n* `suite` List of titles of test suites.\n* `success` True if test is succeed, false otherwise.\n* `skipped` True if test is skipped.\n* `time` Test duration.\n* `log` List of errors.\n* `startTime` Milliseconds since epoch that the test started\n* `endTime` Milliseconds since epoch that the test ended\n* `assertionErrors` List of additional error info: \n    * `name` Error name.\n    * `message` Error message.\n    * `actual` Actual data in assertion, serialized to string.\n    * `expected` Expected data in assertion, serialized to string.\n    * `showDiff` True if it is configured by assertion to show diff.\n* `mocha` An optional object listed if you use the `expose` option\n\nThis object will be passed to test reporter.\n\nNB. the start and end times are added by the adapter whereas the duration is calculated by Mocha - as such they probably will not match arithmetically. Ie. `endTime - startTime !== duration`. These fields have been added so that timestamped reports can be matched up with other timestamped reports from the target device (eg. memory profiling data collected outside the browser)\n\n----\n\nFor more information on Karma see the [homepage].\n\n\n[homepage]: http://karma-runner.github.com\n"
  },
  {
    "path": "commitlint.config.js",
    "content": "module.exports = {extends: ['@commitlint/config-conventional']}\n"
  },
  {
    "path": "gruntfile.js",
    "content": "module.exports = function (grunt) {\n  grunt.initConfig({\n    pkgFile: 'package.json',\n    files: {\n      adapter: [\n        'src/adapter.js'\n      ]\n    },\n    build: {\n      adapter: '<%= files.adapter %>'\n    },\n    eslint: {\n      target: [\n        '<%= files.adapter %>',\n        '*.js',\n        'lib/index.js',\n        'tasks/*.js',\n        'test/**/*.js'\n      ]\n    },\n    karma: {\n      adapter: {\n        configFile: 'karma.conf.js',\n        autoWatch: false,\n        singleRun: true,\n        reporters: ['dots']\n      }\n    },\n    'npm-publish': {\n      options: {\n        requires: ['build']\n      }\n    },\n    'npm-contributors': {\n      options: {\n        commitMessage: 'chore: update contributors'\n      }\n    },\n    conventionalChangelog: {\n      release: {\n        options: {\n          changelogOpts: {\n            preset: 'angular'\n          }\n        },\n        src: 'CHANGELOG.md'\n      }\n    },\n    bump: {\n      options: {\n        commitFiles: [\n          'package.json',\n          'CHANGELOG.md'\n        ],\n        commitMessage: 'chore: release v%VERSION%',\n        pushTo: 'upstream'\n      }\n    }\n  })\n\n  require('load-grunt-tasks')(grunt)\n  grunt.loadTasks('tasks')\n  grunt.registerTask('default', ['build', 'eslint', 'test'])\n  grunt.registerTask('test', ['karma'])\n\n  grunt.registerTask('release', 'Build, bump and publish to NPM.', function (type) {\n    grunt.task.run([\n      'npm-contributors',\n      'bump:' + (type || 'patch') + ':bump-only',\n      'build',\n      'conventionalChangelog',\n      'bump-commit',\n      'npm-publish'\n    ])\n  })\n}\n"
  },
  {
    "path": "karma.conf.js",
    "content": "module.exports = function (config) {\n  config.set({\n    frameworks: ['mocha', 'chai', 'sinon'],\n\n    files: [\n      'src/*.js',\n      'test/src/*.js'\n    ],\n\n    browsers: process.env.TRAVIS ? ['Firefox'] : ['Chrome'],\n\n    autoWatch: true,\n\n    plugins: [\n      require.resolve('./'),\n      'karma-chai',\n      'karma-sinon',\n      'karma-firefox-launcher',\n      'karma-chrome-launcher'\n    ]\n  })\n}\n"
  },
  {
    "path": "lib/index.js",
    "content": "var path = require('path')\nvar extend = require('util')._extend\nvar minimist = require('minimist')\n\nvar createPattern = function (path) {\n  return {pattern: path, included: true, served: true, watched: false}\n}\n\nvar initMocha = function (files, config) {\n  var mochaPath = path.dirname(require.resolve('mocha'))\n  files.unshift(createPattern(path.join(__dirname, 'adapter.js')))\n\n  config = config || {}\n  config.client = config.client || {}\n  var mochaConfig = config.client.mocha = getMochaOpts(config.client.mocha || {})\n\n  if (mochaConfig.require && mochaConfig.require.map) {\n    mochaConfig.require.map(function (requirePath) {\n      return files.unshift(createPattern(requirePath))\n    })\n  }\n\n  files.unshift(createPattern(path.join(mochaPath, 'mocha.js')))\n\n  if (mochaConfig.reporter) {\n    files.unshift(createPattern(path.join(mochaPath, 'mocha.css')))\n  }\n}\n\ninitMocha.$inject = ['config.files', 'config']\n\nmodule.exports = {\n  'framework:mocha': ['factory', initMocha]\n}\n\nfunction getMochaOpts (mochaConfig) {\n  var optsPath = typeof mochaConfig.opts === 'string' ? mochaConfig.opts : 'test/mocha.opts'\n\n  if (!mochaConfig.opts) {\n    return mochaConfig\n  }\n\n  delete mochaConfig.opts\n\n  var fs = require('fs')\n  if (!fs.existsSync(optsPath)) {\n    return mochaConfig\n  }\n\n  return extend(normalizeOpts(minimist(fs.readFileSync(optsPath, 'utf8')\n    .replace(/\\\\\\s/g, '%20')\n    .split(/\\s/)\n    .filter(Boolean)\n    .map(function (value) {\n      return value.replace(/%20/g, ' ')\n    }))), mochaConfig)\n\n  function normalizeOpts (opts) {\n    opts = [\n      'require',\n\n      'ui',\n      'reporter',\n      'globals',\n      'grep',\n      'timeout',\n      'slow',\n      'bail',\n      'ignoreLeaks'\n    ].reduce(function (result, optName) {\n      if (opts.hasOwnProperty(optName)) {\n        result[optName] = opts[optName]\n      }\n\n      return result\n    }, {})\n\n    opts.require = [].concat(opts.require || [])\n\n    return opts\n  }\n}\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"karma-mocha\",\n  \"version\": \"2.0.1\",\n  \"description\": \"A Karma plugin. Adapter for Mocha testing framework.\",\n  \"main\": \"lib/index.js\",\n  \"sharedKarmaFiles\": {\n    \"editorconfig\": \".editorconfig\",\n    \"gitattributes\": \".gitattributes\"\n  },\n  \"scripts\": {\n    \"test\": \"grunt test\",\n    \"test:lib\": \"mocha test/lib\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git://github.com/karma-runner/karma-mocha.git\"\n  },\n  \"keywords\": [\n    \"karma-plugin\",\n    \"karma-adapter\",\n    \"mocha\"\n  ],\n  \"author\": \"Vojta Jina <vojta.jina@gmail.com>\",\n  \"dependencies\": {\n    \"minimist\": \"^1.2.3\"\n  },\n  \"devDependencies\": {\n    \"chai\": \"^3.4.1\",\n    \"eslint\": \"^4.18.2\",\n    \"eslint-config-standard\": \"^5.1.0\",\n    \"eslint-plugin-promise\": \"^1.0.8\",\n    \"eslint-plugin-react\": \"^5.2.2\",\n    \"eslint-plugin-standard\": \"^1.3.2\",\n    \"grunt\": \"~1.0\",\n    \"grunt-auto-release\": \"~0.0.2\",\n    \"grunt-bump\": \"~0.8.0\",\n    \"grunt-conventional-changelog\": \"^6.0.1\",\n    \"grunt-eslint\": \"^18.0.0\",\n    \"grunt-karma\": \"2.x\",\n    \"grunt-npm\": \"~0.0.2\",\n    \"karma\": \"^1.0.0\",\n    \"karma-chai\": \"^0.1.0\",\n    \"karma-chrome-launcher\": \"^1.0.0\",\n    \"karma-firefox-launcher\": \"^1.0.0\",\n    \"karma-sinon\": \"^1.0.3\",\n    \"load-grunt-tasks\": \"^3.2.0\",\n    \"mocha\": \"^3.0.0\",\n    \"mock-fs\": \"^4.10.1\",\n    \"shared-karma-files\": \"git://github.com/karma-runner/shared-karma-files.git#82ae8d02\",\n    \"sinon\": \"^1.17.2\",\n    \"@semantic-release/changelog\": \"^3.0.6\",\n    \"@semantic-release/git\": \"^7.0.18\",\n    \"semantic-release\": \"^15.14.0\",\n    \"@commitlint/cli\": \"^8.3.4\",\n    \"@commitlint/config-conventional\": \"^8.3.4\",\n    \"husky\": \"^4.0.3\"\n  },\n  \"husky\": {\n    \"hooks\": {\n      \"commit-msg\": \"commitlint -E HUSKY_GIT_PARAMS\"\n    }\n  },\n  \"license\": \"MIT\",\n  \"contributors\": [\n    \"Maksim Ryzhikov <rv.maksim@gmail.com>\",\n    \"Friedel Ziegelmayer <friedel.ziegelmayer@gmail.com>\",\n    \"dignifiedquire <friedel.ziegelmayer@gmail.com>\",\n    \"Jordan Klassen <jordan@vidigami.com>\",\n    \"Martin Hansen <martin@martinhansen.no>\",\n    \"Mark Ethan Trostler <mark@zzo.com>\",\n    \"Dave Geddes <davidcgeddes@gmail.com>\",\n    \"Aliaksei Shytkin <e79eas@gmail.com>\",\n    \"Pawel Kozlowski <pkozlowski.opensource@gmail.com>\",\n    \"Christopher Hiller <boneskull@boneskull.com>\",\n    \"Lukasz Bandzarewicz <lucassus@gmail.com>\",\n    \"Jonathan Knapp <jon@coffeeandcode.com>\",\n    \"Karolis Narkevicius <karolis.n@gmail.com>\",\n    \"Mark Trostler <mark@zzo.com>\",\n    \"Peter Halliday <pghalliday@gmail.com>\",\n    \"Raphael Luba <raphael@leanbyte.com>\",\n    \"Sahat Yalkabov <sakhat@gmail.com>\",\n    \"Tim Macfarlane <timmacfarlane@gmail.com>\",\n    \"Vova Bilonenko <bilonenko.v@gmail.com>\",\n    \"dej611 <marco@terraling.com>\",\n    \"eiriksm <eirik@morland.no>\",\n    \"patrick kettner <patrickkettner@gmail.com>\",\n    \"Aymeric Beaumet <aymeric@beaumet.me>\",\n    \"Christian Schlensker <christian@cswebartisan.com>\",\n    \"Christian Schulze <christian.schulze@mywave.me>\",\n    \"Ciro S. Costa <ciro.costa@usp.br>\",\n    \"Dan Thareja <danthareja@gmail.com>\",\n    \"Darryl Pogue <darryl@dpogue.ca>\",\n    \"Darryl Pogue <dvpdiner2@gmail.com>\",\n    \"JONATHAN PARK <jonathan@silvenstudios.com>\",\n    \"James Morris <jamie@maloric.com>\",\n    \"Jason Divock <jdivock@gmail.com>\",\n    \"Jeff Jagoda <jeffrey.jagoda@gmail.com>\"\n  ]\n}\n"
  },
  {
    "path": "release.config.js",
    "content": "module.exports = {\n  debug: true,\n  branch: 'master',\n  verifyConditions: [\n    '@semantic-release/changelog',\n    '@semantic-release/npm',\n    '@semantic-release/github'\n  ],\n  prepare: [\n    '@semantic-release/changelog',\n    '@semantic-release/npm',\n    '@semantic-release/git'\n  ],\n  publish: [\n    '@semantic-release/npm',\n    '@semantic-release/github'\n  ],\n  success: [\n    '@semantic-release/github'\n  ]\n}\n"
  },
  {
    "path": "src/adapter.js",
    "content": "// backwards compatible version of (Array|String).prototype.includes\nvar includes = function (collection, element, startIndex) {\n  if (!collection || !collection.length) {\n    return false\n  }\n\n  // strings support indexOf already\n  if (typeof collection === 'string') {\n    return collection.indexOf(element, startIndex) !== -1\n  }\n\n  if (Array.prototype.indexOf) {\n    return collection.indexOf(element, startIndex) !== -1\n  }\n\n  for (var i = startIndex || 0, len = collection.length; i < len; i++) {\n    if (collection[i] === element) {\n      return true\n    }\n  }\n}\n\n// Date.now polyfill for IE <= 8\nif (!Date.now) {\n  Date.now = function () {\n    return +new Date()\n  }\n}\n\nvar formatError = function (error) {\n  var stack = error.stack\n  var message = error.message\n\n  if (stack) {\n    if (message && !includes(stack, message)) {\n      stack = message + '\\n' + stack\n    }\n\n    // remove mocha stack entries\n    return stack.replace(/\\n.+\\/mocha\\/mocha\\.js\\?\\w*:[\\d:]+\\)?(?=(\\n|$))/g, '')\n  }\n\n  return message\n}\n\nvar processAssertionError = function (error_) {\n  var error\n\n  if (window.Mocha && error_.hasOwnProperty('showDiff')) {\n    error = {\n      name: error_.name,\n      message: error_.message,\n      showDiff: error_.showDiff\n    }\n\n    if (error.showDiff) {\n      error.actual = window.Mocha.utils.stringify(error_.actual)\n      error.expected = window.Mocha.utils.stringify(error_.expected)\n    }\n  }\n\n  return error\n}\n\n// non-compliant version of Array::reduce.call (requires memo argument)\nvar arrayReduce = function (array, reducer, memo) {\n  for (var i = 0, len = array.length; i < len; i++) {\n    memo = reducer(memo, array[i])\n  }\n  return memo\n}\n\nvar createMochaReporterNode = function () {\n  var mochaRunnerNode = document.createElement('div')\n  mochaRunnerNode.setAttribute('id', 'mocha')\n  document.body.appendChild(mochaRunnerNode)\n}\n\nvar haveMochaConfig = function (karma) {\n  return karma.config && karma.config.mocha\n}\n\nvar reportTestResult = function (karma, test) {\n  var skipped = test.pending === true\n\n  var result = {\n    id: '',\n    description: test.title,\n    suite: [],\n    success: test.state === 'passed',\n    skipped: skipped,\n    pending: skipped,\n    time: skipped ? 0 : test.duration,\n    log: test.$errors || [],\n    assertionErrors: test.$assertionErrors || [],\n    startTime: test.$startTime,\n    endTime: Date.now()\n  }\n\n  var pointer = test.parent\n  while (!pointer.root) {\n    result.suite.unshift(pointer.title)\n    pointer = pointer.parent\n  }\n\n  if (haveMochaConfig(karma) && karma.config.mocha.expose && karma.config.mocha.expose.forEach) {\n    result.mocha = {}\n    karma.config.mocha.expose.forEach(function (prop) {\n      if (test.hasOwnProperty(prop)) {\n        result.mocha[prop] = test[prop]\n      }\n    })\n  }\n\n  karma.result(result)\n}\n\nvar createMochaReporterConstructor = function (tc, pathname) {\n  var isDebugPage = /debug.html$/.test(pathname)\n\n  // Set custom reporter on debug page\n  if (isDebugPage && haveMochaConfig(tc) && tc.config.mocha.reporter) {\n    createMochaReporterNode()\n    return tc.config.mocha.reporter\n  }\n\n  // TODO(vojta): error formatting\n  return function (runner) {\n    // runner events\n    // - start\n    // - end\n    // - suite\n    // - suite end\n    // - test\n    // - test end\n    // - pass\n    // - fail\n    // - pending\n\n    runner.on('start', function () {\n      tc.info({total: runner.total})\n    })\n\n    runner.on('end', function () {\n      tc.complete({\n        coverage: window.__coverage__\n      })\n    })\n\n    runner.on('test', function (test) {\n      test.$startTime = Date.now()\n      test.$errors = []\n      test.$assertionErrors = []\n    })\n\n    runner.on('pending', function (test) {\n      test.pending = true\n    })\n\n    runner.on('fail', function (test, error) {\n      var simpleError = formatError(error)\n      var assertionError = processAssertionError(error)\n\n      if (test.type === 'hook') {\n        test.$errors = isDebugPage ? [error] : [simpleError]\n        test.$assertionErrors = assertionError ? [assertionError] : []\n        reportTestResult(tc, test)\n      } else {\n        test.$errors.push(isDebugPage ? error : simpleError)\n        if (assertionError) test.$assertionErrors.push(assertionError)\n      }\n    })\n\n    runner.on('test end', function (test) {\n      reportTestResult(tc, test)\n    })\n  }\n}\n/* eslint-disable no-unused-vars */\nvar createMochaStartFn = function (mocha) {\n  /* eslint-enable no-unused-vars */\n  return function (config) {\n    var clientArguments\n    config = config || {}\n    clientArguments = config.args\n\n    if (clientArguments) {\n      if (Object.prototype.toString.call(clientArguments) === '[object Array]') {\n        arrayReduce(clientArguments, function (isGrepArg, arg) {\n          if (isGrepArg) {\n            mocha.grep(new RegExp(arg))\n          } else if (arg === '--grep') {\n            return true\n          } else {\n            var match = /--grep=(.*)/.exec(arg)\n\n            if (match) {\n              mocha.grep(new RegExp(match[1]))\n            }\n          }\n          return false\n        }, false)\n      }\n\n      /**\n       * TODO(maksimrv): remove when karma-grunt plugin will pass\n       * clientArguments how Array\n       */\n      if (clientArguments.grep) {\n        mocha.grep(clientArguments.grep)\n      }\n    }\n\n    mocha.run()\n  }\n}\n\n// Default configuration\nvar mochaConfig = {\n  reporter: createMochaReporterConstructor(window.__karma__, window.location.pathname),\n  ui: 'bdd',\n  globals: ['__cov*']\n}\n\n// Pass options from client.mocha to mocha\n/* eslint-disable no-unused-vars */\nvar createConfigObject = function (karma) {\n  /* eslint-enable no-unused-vars */\n\n  if (!karma.config || !karma.config.mocha) {\n    return mochaConfig\n  }\n\n  // Copy all properties to mochaConfig\n  for (var key in karma.config.mocha) {\n    // except for reporter, require, or expose\n    if (includes(['reporter', 'require', 'expose'], key)) {\n      continue\n    }\n\n    // and merge the globals if they exist.\n    if (key === 'globals') {\n      mochaConfig.globals = mochaConfig.globals.concat(karma.config.mocha[key])\n      continue\n    }\n\n    mochaConfig[key] = karma.config.mocha[key]\n  }\n  return mochaConfig\n}\n"
  },
  {
    "path": "src/adapter.wrapper",
    "content": ";(function (window) {\n\n%CONTENT%\n\n  window.__karma__.start = createMochaStartFn(window.mocha)\n  window.mocha.setup(createConfigObject(window.__karma__))\n})(window)\n"
  },
  {
    "path": "tasks/build.js",
    "content": "module.exports = function (grunt) {\n  /**\n   * Build given file - wrap it with a function call\n   * TODO(vojta): compile with uglify-js\n   */\n  grunt.registerMultiTask('build', 'Wrap given file into a function call.', function () {\n    var src = grunt.file.expand(this.data).pop()\n    var dest = src.replace('src/', 'lib/')\n    var wrapper = src.replace('.js', '.wrapper')\n\n    grunt.file.copy(wrapper, dest, {process: function (content) {\n      var wrappers = content.split(/%CONTENT%\\r?\\n/)\n      return wrappers[0] + grunt.file.read(src) + wrappers[1]\n    }})\n\n    grunt.log.ok('Created ' + dest)\n  })\n}\n"
  },
  {
    "path": "test/lib/.eslintrc",
    "content": "{\n  \"env\": {\n    \"mocha\": true\n  }\n}\n"
  },
  {
    "path": "test/lib/index.spec.js",
    "content": "var mock = require('mock-fs')\nvar expect = require('chai').expect\nvar initMocha = require('../../lib')['framework:mocha'][1]\n\ndescribe('framework:mocha', function () {\n  var files\n\n  beforeEach(function () {\n    files = createMockFiles()\n  })\n\n  it('should add adapter.js', function () {\n    initMocha(files)\n\n    expect(files[1].pattern).to.contain('adapter.js')\n  })\n\n  it('should add mocha.js', function () {\n    initMocha(files)\n\n    expect(files[0].pattern).to.contain('mocha.js')\n  })\n\n  it('should add required files', function () {\n    var mochaConfig = {require: ['foo.js']}\n\n    initMocha(files, createMochaConfig(mochaConfig))\n\n    expect(files[1].pattern).to.contain('foo.js')\n  })\n\n  it('should add mocha.css if we define reporter in config', function () {\n    var mochaConfig = {reporter: 'html'}\n\n    initMocha(files, createMochaConfig(mochaConfig))\n\n    expect(files[0].pattern).to.contain('mocha.css')\n  })\n\n  describe('load mocha.opts as a configuration file', function () {\n    beforeEach(function () {\n      mock({\n        'test/mocha.opts': [\n          '--sort',\n\n          '--require should',\n          '--reporter dot',\n          '--ui bdd',\n          '--globals foo',\n          '--globals bar',\n          '--timeout 100',\n          '--slow 200',\n          '--grep zoo',\n          '--bail',\n          '--ignoreLeaks'\n        ].join('\\n'),\n        'test/foo.opts': '--ui tdd'\n      })\n    })\n\n    afterEach(function () {\n      mock.restore()\n    })\n\n    it('should read mocha options from test/mocha.opts file by default', function () {\n      var config = createMochaConfig({opts: true})\n\n      initMocha(files, config)\n\n      expect(config.client.mocha.require).to.eql(['should'])\n      expect(config.client.mocha.globals).to.eql(['foo', 'bar'])\n      expect(config.client.mocha.reporter).to.equal('dot')\n      expect(config.client.mocha.ui).to.equal('bdd')\n    })\n\n    it('should set only supported options', function () {\n      var config = createMochaConfig({opts: true})\n\n      initMocha(files, config)\n\n      expect(config.client.mocha).to.eql({\n        require: ['should'],\n\n        ui: 'bdd',\n        reporter: 'dot',\n        globals: ['foo', 'bar'],\n        grep: 'zoo',\n\n        timeout: 100,\n        slow: 200,\n        bail: true,\n        ignoreLeaks: true\n      })\n    })\n\n    it('should rewrite options from mocha.opts by options from config', function () {\n      var config = createMochaConfig({opts: true, ui: 'tdd', globals: ['zoo']})\n\n      initMocha(files, config)\n\n      expect(config.client.mocha.require).to.eql(['should'])\n      expect(config.client.mocha.globals).to.eql(['zoo'])\n      expect(config.client.mocha.reporter).to.equal('dot')\n      expect(config.client.mocha.ui).to.equal('tdd')\n    })\n\n    it('should pass custom mocha.opts path', function () {\n      var config = createMochaConfig({opts: 'test/foo.opts'})\n\n      initMocha(files, config)\n\n      expect(config.client.mocha.ui).to.equal('tdd')\n    })\n  })\n})\n\nfunction createMockFiles () {\n  return []\n}\n\nfunction createMochaConfig (mochaConfig) {\n  return {\n    client: {\n      mocha: mochaConfig\n    }\n  }\n}\n"
  },
  {
    "path": "test/src/.eslintrc",
    "content": "{\n  \"env\": {\n    \"mocha\": true,\n    \"browser\": true\n  },\n  \"globals\": {\n    \"expect\": true,\n    \"MockSocket\": true,\n    \"sinon\": true,\n    \"Emitter\": true,\n    \"formatError\": true\n  }\n}\n"
  },
  {
    "path": "test/src/adapter.spec.js",
    "content": "/**\n Tests for adapter/mocha.src.js\n These tests are executed in browser.\n */\n\n/* globals\n createMochaReporterConstructor,\n createMochaReporterNode,\n createMochaStartFn,\n createConfigObject,\n mochaConfig: true,\n formatError: true,\n processAssertionError: true,\n MockSocket: true,\n Emitter: true,\n sinon: true,\n expect: true,\n describe: true,\n beforeEach: true,\n afterEach: true,\n it: true\n */\ndescribe('adapter mocha', function () {\n  var Karma = window.__karma__.constructor\n  var sandbox\n\n  beforeEach(function () {\n    sandbox = sinon.sandbox.create()\n  })\n\n  afterEach(function () {\n    sandbox.restore()\n  })\n\n  describe('createMochaReporterConstructor', function () {\n    beforeEach(function () {\n      this.karma = new Karma(function (method, args) { })\n      this.karma.config = {\n        mocha: {\n          reporter: 'html'\n        }\n      }\n\n      sandbox.stub(window, 'createMochaReporterNode')\n    })\n\n    it('should take reporter from client config on debug page', function () {\n      expect(createMochaReporterConstructor(this.karma, '/debug.html')).to.equal('html')\n    })\n\n    it('should create node for mocha reporter', function () {\n      createMochaReporterConstructor(this.karma, '/debug.html')\n\n      expect(createMochaReporterNode.called).to.equal(true)\n    })\n\n    it('should define console reporter if does not pass reporter in config', function () {\n      this.karma.config.mocha.reporter = null\n\n      expect(createMochaReporterConstructor(this.karma, '/debug.html')).not.to.equal(null)\n    })\n  })\n\n  describe('reporter', function () {\n    var runner, tc\n\n    beforeEach(function () {\n      tc = new Karma(function (method, args) { })\n      runner = new Emitter()\n      var reporter = new (createMochaReporterConstructor(tc))(runner) // eslint-disable-line\n    })\n\n    describe('start', function () {\n      it('should report total number of specs', function () {\n        runner.total = 12\n        sandbox.spy(tc, 'info')\n\n        runner.emit('start')\n        expect(tc.info.getCall(0).args).to.deep.eq([{total: 12}])\n      })\n    })\n\n    describe('end', function () {\n      it('should report complete', function () {\n        sandbox.spy(tc, 'complete')\n\n        runner.emit('end')\n        expect(tc.complete.called).to.eq(true)\n      })\n    })\n\n    describe('test end', function () {\n      it('should report result', function () {\n        var beforeStartTime = Date.now()\n        var DURATION = 200\n\n        sandbox.stub(tc, 'result', function (result) {\n          var afterEndTime = Date.now()\n          expect(result.id).to.not.be.undefined\n          expect(result.description).to.eq('should do something')\n          expect(result.suite instanceof Array).to.eq(true)\n          expect(result.success).to.eq(true)\n          expect(result.skipped).to.to.eql(false)\n          expect(result.pending).to.to.eql(false)\n          expect(result.log instanceof Array).to.eq(true)\n          expect(result.assertionErrors instanceof Array).to.eq(true)\n          expect(result.startTime).to.be.at.least(beforeStartTime)\n          expect(result.endTime - result.startTime).to.be.at.least(DURATION)\n          expect(result.endTime).to.be.at.most(afterEndTime)\n          expect(result.time).to.eq(DURATION)\n        })\n\n        var mockMochaResult = {\n          duration: DURATION,\n          parent: {title: 'desc2', parent: {title: 'desc1', root: true}, root: false},\n          state: 'passed',\n          title: 'should do something'\n        }\n\n        runner.emit('test', mockMochaResult)\n        // wait at least 200ms to get different start and end times\n        var afterStartTime = Date.now()\n        while (Date.now() - afterStartTime < DURATION) {}\n        runner.emit('test end', mockMochaResult)\n\n        expect(tc.result.called).to.eq(true)\n      })\n\n      it('should report skipped result', function () {\n        sandbox.stub(tc, 'result', function (result) {\n          expect(result.skipped).to.eq(true)\n          expect(result.pending).to.eq(true)\n        })\n\n        var mockMochaResult = {\n          parent: {root: true}\n        }\n\n        runner.emit('pending', mockMochaResult)\n        runner.emit('test end', mockMochaResult)\n\n        expect(tc.result.called).to.eq(true)\n      })\n\n      it('should report time 0 for skipped tests', function () {\n        sandbox.stub(tc, 'result', function (result) {\n          expect(result.skipped).to.eq(true)\n          expect(result.time).to.eq(0)\n        })\n\n        var mockMochaResult = {\n          pending: true,\n          parent: {root: true}\n        }\n\n        runner.emit('test', mockMochaResult)\n        runner.emit('test end', mockMochaResult)\n\n        expect(tc.result.called).to.eq(true)\n      })\n\n      it('should report failed result', function () {\n        sandbox.stub(tc, 'result', function (result) {\n          expect(result.success).to.to.eql(false)\n          expect(result.skipped).to.to.eql(false)\n          expect(result.log).to.deep.eq(['Big trouble.', 'Another fail.'])\n          expect(result.assertionErrors).to.be.empty\n        })\n\n        var mockMochaResult = {\n          parent: {title: 'desc2', root: true},\n          state: 'failed',\n          title: 'should do something'\n        }\n\n        runner.emit('test', mockMochaResult)\n        runner.emit('fail', mockMochaResult, {message: 'Big trouble.'})\n        runner.emit('pass', mockMochaResult)\n        runner.emit('fail', mockMochaResult, {message: 'Another fail.'})\n        runner.emit('test end', mockMochaResult)\n\n        expect(tc.result.called).to.eq(true)\n      })\n\n      it('should report failed mocha result', function () {\n        sandbox.stub(tc, 'result', function (result) {\n          expect(result.log).to.deep.eq(['Big trouble.', 'Another fail.'])\n          expect(result.assertionErrors).to.deep.eq([{\n            name: 'AssertionError',\n            message: 'Big trouble.',\n            showDiff: false\n          }])\n        })\n\n        var mockMochaResult = {\n          parent: {title: 'desc2', root: true},\n          state: 'failed',\n          title: 'should do something'\n        }\n\n        runner.emit('test', mockMochaResult)\n        runner.emit('fail', mockMochaResult, {\n          name: 'AssertionError',\n          message: 'Big trouble.',\n          showDiff: false,\n          actual: 1,\n          expected: 2\n        })\n        runner.emit('fail', mockMochaResult, {message: 'Another fail.'})\n        runner.emit('test end', mockMochaResult)\n\n        expect(tc.result.called).to.eq(true)\n      })\n\n      it('should report suites', function () {\n        sandbox.stub(tc, 'result', function (result) {\n          expect(result.suite).to.deep.eq(['desc1', 'desc2'])\n        })\n\n        var mockMochaResult = {\n          parent: {title: 'desc2', parent: {title: 'desc1', parent: {root: true}, root: false}, root: false},\n          title: 'should do something'\n        }\n\n        runner.emit('test', mockMochaResult)\n        runner.emit('test end', mockMochaResult)\n\n        expect(tc.result.called).to.eq(true)\n      })\n\n      it('should report mocha properties through the `expose` option', function () {\n        tc.config = {\n          mocha: {\n            expose: ['body', 'hello']\n          }\n        }\n\n        sandbox.stub(tc, 'result', function (result) {\n          expect(result.mocha.body).to.eq('function(){ expect(false).to.be(true) }')\n          expect(result.mocha.hello).to.eq('world')\n        })\n\n        var mockMochaResult = {\n          parent: {title: 'desc2', root: true},\n          title: 'should do something',\n          body: 'function(){ expect(false).to.be(true) }',\n          hello: 'world'\n        }\n\n        runner.emit('test end', mockMochaResult)\n\n        expect(tc.result.called).to.eq(true)\n      })\n\n      it('should not report mocha properties if `expose` is not configured', function () {\n        sandbox.stub(tc, 'result', function (result) {\n          expect(result.mocha).to.not.exist\n        })\n\n        var mockMochaResult = {\n          parent: {title: 'desc2', root: true},\n          title: 'should do something',\n          body: 'function(){ expect(false).to.be(true) }',\n          hello: 'world'\n        }\n\n        runner.emit('test end', mockMochaResult)\n\n        expect(tc.result.called).to.eq(true)\n      })\n    })\n\n    describe('fail', function () {\n      it('should end test on hook failure', function () {\n        sandbox.stub(tc, 'result', function (result) {\n          expect(result.success).to.to.eql(false)\n          expect(result.skipped).to.to.eql(false)\n          expect(result.log).to.deep.eq(['hook failed'])\n        })\n\n        var mockMochaHook = {\n          type: 'hook',\n          title: 'scenario \"before each\" hook',\n          parent: {title: 'desc1', root: true}\n        }\n\n        runner.emit('hook', mockMochaHook)\n        runner.emit('fail', mockMochaHook, {message: 'hook failed'})\n\n        expect(tc.result.called).to.eq(true)\n      })\n\n      it('should not emit test end on hook failure', function () {\n        const testEndStub = sandbox.stub()\n        runner.on('test end', testEndStub)\n\n        var mockMochaHook = {\n          type: 'hook',\n          title: 'scenario \"before each\" hook',\n          parent: {title: 'desc1', root: true}\n        }\n\n        runner.emit('hook', mockMochaHook)\n        runner.emit('fail', mockMochaHook, {message: 'hook failed'})\n        expect(testEndStub.called).to.eq(false)\n      })\n\n      it('should end the test only once on uncaught exceptions', function () {\n        sandbox.stub(tc, 'result', function (result) {\n          expect(result.success).to.to.eql(false)\n          expect(result.skipped).to.to.eql(false)\n          expect(result.log).to.deep.eq(['Uncaught error.'])\n        })\n\n        var mockMochaResult = {\n          parent: {title: 'desc2', root: true},\n          state: 'failed',\n          title: 'should do something'\n        }\n\n        runner.emit('test', mockMochaResult)\n        runner.emit('fail', mockMochaResult, {message: 'Uncaught error.', uncaught: true})\n        runner.emit('test end', mockMochaResult)\n\n        expect(tc.result.called).to.eq(true)\n      })\n\n      it('should remove mocha stack entries', function () {\n        sandbox.stub(tc, 'result', function (result) {\n          var log = result.log[0]\n          expect(log).to.not.contain('/mocha/mocha.js')\n          expect(log).to.contain('/spec/controllers/list/formCtrlSpec.js')\n        })\n\n        var mockMochaResult = {\n          parent: {root: true}\n        }\n\n        var stack =\n          'at $httpBackend (http://localhost:8080/base/app/bower_components/angular-mocks/angular-mocks.js?506e0a37bcd764ec63da3fd7005bf56592b3df32:1149)\\n' +\n          'at sendReq (http://localhost:8080/base/app/bower_components/angular/angular.js?7deca05396a4331b08f812e4962ef9df1d9de0b5:8408)\\n' +\n          'at http://localhost:8080/base/app/bower_components/angular/angular.js?7deca05396a4331b08f812e4962ef9df1d9de0b5:8125\\n' +\n          'at http://localhost:8080/base/test/client/spec/controllers/list/formCtrlSpec.js?67eaca0f801cf45a86802a262618a6cfdc6a47be:110\\n' +\n          'at invoke (http://localhost:8080/base/app/bower_components/angular/angular.js?7deca05396a4331b08f812e4962ef9df1d9de0b5:4068)\\n' +\n          'at workFn (http://localhost:8080/base/app/bower_components/angular-mocks/angular-mocks.js?506e0a37bcd764ec63da3fd7005bf56592b3df32:2194)\\n' +\n          'at callFn (http://localhost:8080/base/node_modules/mocha/mocha.js?529c1ea3966a13c21efca5afe9a2317dafcd8abc:4338)\\n' +\n          'at http://localhost:8080/base/node_modules/mocha/mocha.js?529c1ea3966a13c21efca5afe9a2317dafcd8abc:4331\\n' +\n          'at next (http://localhost:8080/base/node_modules/mocha/mocha.js?529c1ea3966a13c21efca5afe9a2317dafcd8abc:4653)\\n' +\n          'at http://localhost:8080/base/node_modules/mocha/mocha.js?529c1ea3966a13c21efca5afe9a2317dafcd8abc:4663\\n' +\n          'at next (http://localhost:8080/base/node_modules/mocha/mocha.js?529c1ea3966a13c21efca5afe9a2317dafcd8abc:4601)\\n'\n\n        runner.emit('test', mockMochaResult)\n        runner.emit('fail', mockMochaResult, {message: 'Another fail.', stack: stack})\n        runner.emit('test end', mockMochaResult)\n\n        expect(tc.result.called).to.eq(true)\n      })\n\n      it('should not remove escaped strings containing mocha stack entries', function () {\n        sandbox.stub(tc, 'result', function (result) {\n          var log = result.log[0]\n          expect(log).to.contain('something important that contains an escaped mocha stack trace')\n        })\n\n        var mockMochaResult = {\n          parent: {root: true}\n        }\n\n        var stack =\n          'something important that contains an escaped mocha stack trace at workFn (http://localhost:8080/base/app/bower_components/angular-mocks/angular-mocks.js?506e0a37bcd764ec63da3fd7005bf56592b3df32:2194)\\\\n at callFn (http://localhost:8080/base/node_modules/mocha/mocha.js?312499f61e38c4f82b2789b388ced378202a1e75:4471:21)\\\\n    at Hook.Runnable.run (http://localhost:8080/base/node_modules/mocha/mocha.js?312499f61e38c4f82b2789b388ced378202a1e75:4464:7)\\\\n\\n' +\n          'at $httpBackend (http://localhost:8080/base/app/bower_components/angular-mocks/angular-mocks.js?506e0a37bcd764ec63da3fd7005bf56592b3df32:1149)\\n' +\n          'at sendReq (http://localhost:8080/base/app/bower_components/angular/angular.js?7deca05396a4331b08f812e4962ef9df1d9de0b5:8408)\\n' +\n          'at http://localhost:8080/base/app/bower_components/angular/angular.js?7deca05396a4331b08f812e4962ef9df1d9de0b5:8125\\n' +\n          'at http://localhost:8080/base/test/client/spec/controllers/list/formCtrlSpec.js?67eaca0f801cf45a86802a262618a6cfdc6a47be:110\\n' +\n          'at invoke (http://localhost:8080/base/app/bower_components/angular/angular.js?7deca05396a4331b08f812e4962ef9df1d9de0b5:4068)\\n' +\n          'at workFn (http://localhost:8080/base/app/bower_components/angular-mocks/angular-mocks.js?506e0a37bcd764ec63da3fd7005bf56592b3df32:2194)\\n' +\n          'at callFn (http://localhost:8080/base/node_modules/mocha/mocha.js?529c1ea3966a13c21efca5afe9a2317dafcd8abc:4338)\\n' +\n          'at http://localhost:8080/base/node_modules/mocha/mocha.js?529c1ea3966a13c21efca5afe9a2317dafcd8abc:4331\\n' +\n          'at next (http://localhost:8080/base/node_modules/mocha/mocha.js?529c1ea3966a13c21efca5afe9a2317dafcd8abc:4653)\\n' +\n          'at http://localhost:8080/base/node_modules/mocha/mocha.js?529c1ea3966a13c21efca5afe9a2317dafcd8abc:4663\\n' +\n          'at next (http://localhost:8080/base/node_modules/mocha/mocha.js?529c1ea3966a13c21efca5afe9a2317dafcd8abc:4601)\\n'\n\n        runner.emit('test', mockMochaResult)\n        runner.emit('fail', mockMochaResult, {message: 'Another fail.', stack: stack})\n        runner.emit('test end', mockMochaResult)\n\n        expect(tc.result.called).to.eq(true)\n      })\n    })\n  })\n\n  describe('createMochaStartFn', function () {\n    beforeEach(function () {\n      this.mockMocha = {\n        grep: function () {\n        },\n        run: function () {\n        }\n      }\n    })\n\n    it('should pass grep argument to mocha', function () {\n      sandbox.spy(this.mockMocha, 'grep')\n\n      createMochaStartFn(this.mockMocha)({\n        args: ['--grep', 'test test']\n      })\n\n      expect(this.mockMocha.grep.getCall(0).args).to.deep.eq([/test test/])\n    })\n\n    it('should pass grep argument to mocha if we called the run with --grep=xxx', function () {\n      sandbox.spy(this.mockMocha, 'grep')\n\n      createMochaStartFn(this.mockMocha)({\n        args: ['--grep=test test']\n      })\n\n      expect(this.mockMocha.grep.getCall(0).args).to.deep.eq([/test test/])\n    })\n\n    it('should pass grep argument to mocha if config.args contains property grep', function () {\n      sandbox.spy(this.mockMocha, 'grep')\n\n      createMochaStartFn(this.mockMocha)({\n        args: {\n          grep: 'test'\n        }\n      })\n\n      expect(this.mockMocha.grep.getCall(0).args).to.deep.eq(['test'])\n    })\n\n    it('should not require client arguments', function () {\n      var that = this\n\n      expect(function () {\n        createMochaStartFn(that.mockMocha)({})\n      }).to.not.throw()\n    })\n  })\n\n  describe('createConfigObject', function () {\n    beforeEach(function () {\n      this.originalMochaConfig = mochaConfig\n\n      mochaConfig = {\n        ui: 'bdd',\n        globals: ['__cov']\n      }\n\n      this.karma = new Karma(new MockSocket(), null, null, null, {search: ''})\n      this.karma.config = {}\n    })\n\n    afterEach(function () {\n      mochaConfig = this.originalMochaConfig\n    })\n\n    it('should return default config if karma does not define client config', function () {\n      this.karma.config = null\n\n      expect(createConfigObject(this.karma)).to.eq(mochaConfig)\n    })\n\n    it('should return default config if the client config havent properties mocha', function () {\n      expect(createConfigObject(this.karma)).to.eq(mochaConfig)\n    })\n\n    it('should pass client.mocha options to mocha config', function () {\n      this.karma.config.mocha = {\n        slow: 10\n      }\n\n      expect(createConfigObject(this.karma).slow).to.eq(10)\n    })\n\n    it('should rewrite ui options from default config', function () {\n      this.karma.config.mocha = {\n        ui: 'tdd'\n      }\n\n      expect(createConfigObject(this.karma).ui).to.eq('tdd')\n    })\n\n    it('should ignore propertie reporter from client config', function () {\n      this.karma.config.mocha = {\n        reporter: 'test'\n      }\n\n      expect(createConfigObject(this.karma).reporter).not.to.eq('test')\n    })\n\n    it('should ignore property require from client config', function () {\n      this.karma.config.mocha = {\n        require: 'test'\n      }\n\n      expect(createConfigObject(this.karma).require).not.to.eq('test')\n    })\n\n    it('should ignore property expose from client config', function () {\n      this.karma.config.mocha = {\n        expose: 'body'\n      }\n\n      expect(createConfigObject(this.karma).expose).not.to.eq('body')\n    })\n\n    it('should merge the globals from client config if they exist', function () {\n      this.karma.config.mocha = {\n        globals: ['test']\n      }\n\n      expect(createConfigObject(this.karma).globals).to.deep.eq(['__cov', 'test'])\n    })\n  })\n\n  describe('formatError', function () {\n    it('should properly format exceptions that contains \\n in their message', function () {\n      var errLines = formatError(new Error('foo\\nbar')).split('\\n')\n      expect(errLines[0]).to.contain('foo')\n      expect(errLines[1]).to.equal('bar')\n      expect(errLines[2]).to.not.contain('foo')\n    })\n  })\n\n  describe('processAssertionError', function () {\n    it('should create object from mocha error', function () {\n      var err = new Error()\n      err.name = 'AssertionError'\n      err.message = 'expected \\'something\\' to deeply equal \\'something else\\''\n      err.showDiff = true\n      err.actual = {baz: 'baz', foo: null, bar: function () {}}\n      err.expected = {baz: 42, foo: undefined}\n\n      var error = processAssertionError(err)\n\n      expect(Object.keys(error)).to.be.eql(['name', 'message', 'showDiff', 'actual', 'expected'])\n      expect(error.name).to.equal('AssertionError')\n      expect(error.message).to.equal('expected \\'something\\' to deeply equal \\'something else\\'')\n      expect(error.showDiff).to.be.true\n      expect(error.actual).to.equal('{\\n  \"bar\": [Function]\\n  \"baz\": \"baz\"\\n  \"foo\": [null]\\n}')\n      expect(error.expected).to.equal('{\\n  \"baz\": 42\\n  \"foo\": [undefined]\\n}')\n    })\n\n    it('should not create object from simple error', function () {\n      var err = new Error('Something wrong')\n\n      var error = processAssertionError(err)\n\n      expect(error).to.be.undefined\n    })\n\n    it('should not pass actual and expected if showDiff is off', function () {\n      var err = new Error()\n      err.message = 'expected \\'something\\' to deeply equal \\'something else\\''\n      err.showDiff = false\n      err.actual = {baz: 'baz', foo: null, bar: function () {}}\n      err.expected = {baz: 42, foo: undefined}\n\n      var error = processAssertionError(err)\n\n      expect(Object.keys(error)).to.be.eql(['name', 'message', 'showDiff'])\n      expect(error.name).to.equal('Error')\n      expect(error.message).to.equal('expected \\'something\\' to deeply equal \\'something else\\'')\n      expect(error.showDiff).to.be.false\n      expect(error).to.not.have.property('actual')\n      expect(error).to.not.have.property('expected')\n    })\n  })\n})\n"
  },
  {
    "path": "test/src/mocks.js",
    "content": "var Emitter = function () {\n  var listeners = {}\n\n  this.on = function (event, fn) {\n    if (!listeners[event]) {\n      listeners[event] = []\n    }\n\n    listeners[event].push(fn)\n  }\n\n  this.emit = function (event) {\n    var eventListeners = listeners[event]\n\n    if (!eventListeners) return\n\n    var i = 0\n    while (i < eventListeners.length) {\n      eventListeners[i].apply(null, Array.prototype.slice.call(arguments, 1))\n      i++\n    }\n  }\n}\n\nvar MockSocket = Emitter // eslint-disable-line no-unused-vars\n"
  },
  {
    "path": "wallaby.js",
    "content": "module.exports = function () {\n  return {\n    files: [\n      'lib/**/*@(.js)'\n    ],\n\n    tests: [\n      './test/lib/**/*.spec@(.js)'\n    ],\n\n    env: {\n      type: 'node'\n    },\n\n    testFramework: 'mocha'\n  }\n}\n"
  }
]