Full Code of karma-runner/karma-mocha for AI

master 537ef7bafb2a cached
24 files
52.3 KB
15.4k tokens
3 symbols
1 requests
Download .txt
Repository: karma-runner/karma-mocha
Branch: master
Commit: 537ef7bafb2a
Files: 24
Total size: 52.3 KB

Directory structure:
gitextract_w97345x5/

├── .eslintrc
├── .gitignore
├── .mailmap
├── .npmignore
├── .travis.yml
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── commitlint.config.js
├── gruntfile.js
├── karma.conf.js
├── lib/
│   └── index.js
├── package.json
├── release.config.js
├── src/
│   ├── adapter.js
│   └── adapter.wrapper
├── tasks/
│   └── build.js
├── test/
│   ├── lib/
│   │   ├── .eslintrc
│   │   └── index.spec.js
│   └── src/
│       ├── .eslintrc
│       ├── adapter.spec.js
│       └── mocks.js
└── wallaby.js

================================================
FILE CONTENTS
================================================

================================================
FILE: .eslintrc
================================================
{
  "extends": "standard"
}

================================================
FILE: .gitignore
================================================
lib/adapter.js
node_modules
npm-debug.log
.idea


================================================
FILE: .mailmap
================================================
<bitwiseman@gmail.com> <lnewman@book.com>
<vojta.jina@gmail.com> <vojta@google.com>
<friedel.ziegelmayer@gmail.com> <dignifiedquire@gmail.com>


================================================
FILE: .npmignore
================================================
.gitignore
.travis.yml
src
test
tasks

Gruntfile.coffee
karma.conf.js
karma-v0.8.conf.js
CONTRIBUTING.md


================================================
FILE: .travis.yml
================================================
sudo: false
language: node_js
node_js:
  - 10
  - 12

services:
  - xvfb

before_install:
  - npm install -g npm

before_script:
  - npm install -g grunt-cli
  - echo "TRAVIS_COMMIT $TRAVIS_COMMIT"
  - echo "TRAVIS_PULL_REQUEST_SHA $TRAVIS_PULL_REQUEST_SHA"
  - COMMIT_TO_VALIDATE=${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT}
  - echo "COMMIT_TO_VALIDATE $COMMIT_TO_VALIDATE"
  - 'if [ "$VALIDATE_COMMIT_MSG" == "true" ]; then ./scripts/validate-commit-msg.sh $COMMIT_TO_VALIDATE; fi'

script:
  - npm run test:lib
  - grunt

after_success:
  # run automated release process with semantic-release
  - echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE, TRAVIS_NODE_VERSION=$TRAVIS_NODE_VERSION"
  - if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_EVENT_TYPE" == "push" && "$TRAVIS_NODE_VERSION" == "12" ]]; then
      semantic-release;
    fi;

================================================
FILE: CHANGELOG.md
================================================
## [2.0.1](https://github.com/karma-runner/karma-mocha/compare/v2.0.0...v2.0.1) (2020-04-29)


### Bug Fixes

* **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))

# [2.0.0](https://github.com/karma-runner/karma-mocha/compare/v1.3.0...v2.0.0) (2020-04-14)


### Features

* **ci:** enable semanitic-release ([5a5b6d5](https://github.com/karma-runner/karma-mocha/commit/5a5b6d52399eab9a20592e3536b3e2df1b3ce9ce))
* Expose 'pending' status ([e847121](https://github.com/karma-runner/karma-mocha/commit/e847121e35f59a498c3b09f87f138621b550629b)), closes [#109](https://github.com/karma-runner/karma-mocha/issues/109)


* Update Node.js versions ([fd64f5b](https://github.com/karma-runner/karma-mocha/commit/fd64f5bcacf2e0de6eeb24772384442bd6a37bed))


### BREAKING CHANGES

* drop support for node 8

<a name="1.3.0"></a>
# [1.3.0](https://github.com/karma-runner/karma-mocha/compare/v1.2.0...v1.3.0) (2016-11-09)


### Bug Fixes

* polyfill Date.now to restore IE compat ([246f25a](https://github.com/karma-runner/karma-mocha/commit/246f25a))
* **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)


### Features

* support mocha opts ([11a0dd8](https://github.com/karma-runner/karma-mocha/commit/11a0dd8)), closes [#99](https://github.com/karma-runner/karma-mocha/issues/99)



<a name="1.2.0"></a>
# [1.2.0](https://github.com/karma-runner/karma-mocha/compare/v1.1.1...v1.2.0) (2016-09-26)


### Bug Fixes

* "remove mocha stack entries" was too greedy ([c893d0a](https://github.com/karma-runner/karma-mocha/commit/c893d0a))


### Features

* **reporter:** add timestamps to results ([7b41f52](https://github.com/karma-runner/karma-mocha/commit/7b41f52))
* **reporter:** expose mocha test properties ([e4eb5fd](https://github.com/karma-runner/karma-mocha/commit/e4eb5fd))



<a name="1.1.1"></a>
## [1.1.1](https://github.com/karma-runner/karma-mocha/compare/v1.1.0...v1.1.1) (2016-06-26)


### Bug Fixes

* handle non existing mochaConfig ([dcb74a5](https://github.com/karma-runner/karma-mocha/commit/dcb74a5))



<a name="1.1.0"></a>
# [1.1.0](https://github.com/karma-runner/karma-mocha/compare/v1.0.1...v1.1.0) (2016-06-26)


### Features

* 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)
* **deps:** update dependencies ([fe04ebb](https://github.com/karma-runner/karma-mocha/commit/fe04ebb))



<a name="1.0.1"></a>
## [1.0.1](https://github.com/karma-runner/karma-mocha/compare/v0.2.2...v1.0.1) (2016-05-02)


### Bug Fixes

* Do not lose stack trace at debug.html ([0b5a392](https://github.com/karma-runner/karma-mocha/commit/0b5a392))



<a name="0.2.2"></a>
## [0.2.2](https://github.com/karma-runner/karma-mocha/compare/v0.2.1...v0.2.2) (2016-02-15)



<a name="0.2.1"></a>
## [0.2.1](https://github.com/karma-runner/karma-mocha/compare/v0.2.0...v0.2.1) (2015-11-13)


### Bug Fixes

* 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))



<a name="0.2.0"></a>
# [0.2.0](https://github.com/karma-runner/karma-mocha/compare/v0.1.10...v0.2.0) (2015-06-22)


### Bug Fixes

* **config:** grep is interpreted as regexp ([01d11e6](https://github.com/karma-runner/karma-mocha/commit/01d11e6))
* **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)
* Drop karma as a peerDependency. ([5c11809](https://github.com/karma-runner/karma-mocha/commit/5c11809))



<a name="0.1.10"></a>
## [0.1.10](https://github.com/karma-runner/karma-mocha/compare/v0.1.9...v0.1.10) (2014-12-04)



<a name="0.1.9"></a>
## [0.1.9](https://github.com/karma-runner/karma-mocha/compare/v0.1.8...v0.1.9) (2014-08-23)


### Bug Fixes

* 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)



<a name="0.1.8"></a>
## [0.1.8](https://github.com/karma-runner/karma-mocha/compare/v0.1.7...v0.1.8) (2014-08-18)


### Bug Fixes

* 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)



<a name="0.1.7"></a>
## [0.1.7](https://github.com/karma-runner/karma-mocha/compare/v0.1.6...v0.1.7) (2014-08-07)



<a name="0.1.6"></a>
## [0.1.6](https://github.com/karma-runner/karma-mocha/compare/v0.1.5...v0.1.6) (2014-07-17)


### Bug Fixes

* correctly prepare the new version (v0.1.5) ([ab2a23f](https://github.com/karma-runner/karma-mocha/commit/ab2a23f))



<a name="0.1.5"></a>
## [0.1.5](https://github.com/karma-runner/karma-mocha/compare/v0.1.4...v0.1.5) (2014-06-16)



<a name="0.1.4"></a>
## [0.1.4](https://github.com/karma-runner/karma-mocha/compare/v0.1.3...v0.1.4) (2014-06-15)


### Features

* 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))



<a name="0.1.3"></a>
## [0.1.3](https://github.com/karma-runner/karma-mocha/compare/v0.1.2...v0.1.3) (2014-03-13)


### Bug Fixes

* grep for grunt-karma ([70aef65](https://github.com/karma-runner/karma-mocha/commit/70aef65))



<a name="0.1.2"></a>
## [0.1.2](https://github.com/karma-runner/karma-mocha/compare/v0.1.1...v0.1.2) (2014-02-18)


### Bug Fixes

* restores the ability to use grep ([2787886](https://github.com/karma-runner/karma-mocha/commit/2787886))



<a name="0.1.1"></a>
## [0.1.1](https://github.com/karma-runner/karma-mocha/compare/v0.1.0...v0.1.1) (2013-11-26)


### Features

* 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)



<a name="0.1.0"></a>
# [0.1.0](https://github.com/karma-runner/karma-mocha/compare/v0.0.4...v0.1.0) (2013-08-06)



<a name="0.0.4"></a>
## [0.0.4](https://github.com/karma-runner/karma-mocha/compare/v0.0.3...v0.0.4) (2013-07-19)


### Features

* remove dump, as karma implements it ([e02af06](https://github.com/karma-runner/karma-mocha/commit/e02af06))



<a name="0.0.3"></a>
## [0.0.3](https://github.com/karma-runner/karma-mocha/compare/v0.0.2...v0.0.3) (2013-07-07)


### Bug Fixes

* config does not have to be defined ([edfa534](https://github.com/karma-runner/karma-mocha/commit/edfa534))



<a name="0.0.2"></a>
## [0.0.2](https://github.com/karma-runner/karma-mocha/compare/4f5470d...v0.0.2) (2013-07-05)


### Bug Fixes

* 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)


================================================
FILE: CONTRIBUTING.md
================================================
Please see the [Contributing to Karma] guide for information on contributing to this project.

[Contributing to Karma]: https://github.com/karma-runner/karma/blob/master/CONTRIBUTING.md


================================================
FILE: LICENSE
================================================
The MIT License

Copyright (C) 2011-2013 Google, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

================================================
FILE: README.md
================================================
# karma-mocha

[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/karma-runner/karma-mocha)
 [![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)

[![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)

> Adapter for the [Mocha](http://mochajs.org/) testing framework.

## Installation

Install `karma-mocha` and `mocha` into to your project via `npm`:

```shell
$ npm install karma-mocha mocha --save-dev
```

`karma-mocha` should work with any version of `mocha`.

Since `karma-mocha` is an adapter for [Karma](http://karma-runner.github.io), you likely have it installed already, but in case you don't:  

```shell
$ npm install karma --save-dev
```

If you're having trouble, Karma provides [detailed instructions](http://karma-runner.github.io/1.0/intro/installation.html) on installation. 

## Configuration
Following code shows the default configuration...
```js
// karma.conf.js
module.exports = function(config) {
  config.set({
    frameworks: ['mocha'],

    files: [
      '*.js'
    ]
  });
};
```

If you want to pass configuration options directly to mocha you can
do this in the following way

```js
// karma.conf.js
module.exports = function(config) {
  config.set({
    frameworks: ['mocha'],

    files: [
      '*.js'
    ],

    client: {
      mocha: {
        // change Karma's debug.html to the mocha web reporter
        reporter: 'html',

        // require specific files after Mocha is initialized
        require: [require.resolve('bdd-lazy-var/bdd_lazy_var_global')],

        // custom ui, defined in required file above
        ui: 'bdd-lazy-var/global',
      }
    }
  });
};
```

If you want run only some tests matching a given pattern you can
do this in the following way

```sh
karma start &
karma run -- --grep=<pattern>
```

or

```js
module.exports = function(config) {
  config.set({
    ...
    client: {
      mocha: {
        grep: '<pattern>', // passed directly to mocha
        ...
      }
      ...
    }
  });
};
```

If you want to expose test properties specific to `mocha`, you can use the `expose` option:

```js
module.exports = function(config) {
  config.set({
    ...
    client: {
      mocha: {
        expose: ['body'] // This will be exposed in a reporter as `result.mocha.body`
        ...
      }
      ...
    }
  });
};
```

If you already have a configuration for Mocha in an opts file, you can use the `opts` option:

```js
module.exports = function(config) {
  config.set({
    ...
    client: {
      mocha: {
        opts: 'test/mocha.opts' // You can set opts to equal true then plugin will load opts from default location 'test/mocha.opts'
        ...
      }
      ...
    }
  });
};
```

## Internals

On the end of each test `karma-mocha` passes to `karma` result object with fields:

* `description` Test title.
* `suite` List of titles of test suites.
* `success` True if test is succeed, false otherwise.
* `skipped` True if test is skipped.
* `time` Test duration.
* `log` List of errors.
* `startTime` Milliseconds since epoch that the test started
* `endTime` Milliseconds since epoch that the test ended
* `assertionErrors` List of additional error info: 
    * `name` Error name.
    * `message` Error message.
    * `actual` Actual data in assertion, serialized to string.
    * `expected` Expected data in assertion, serialized to string.
    * `showDiff` True if it is configured by assertion to show diff.
* `mocha` An optional object listed if you use the `expose` option

This object will be passed to test reporter.

NB. 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)

----

For more information on Karma see the [homepage].


[homepage]: http://karma-runner.github.com


================================================
FILE: commitlint.config.js
================================================
module.exports = {extends: ['@commitlint/config-conventional']}


================================================
FILE: gruntfile.js
================================================
module.exports = function (grunt) {
  grunt.initConfig({
    pkgFile: 'package.json',
    files: {
      adapter: [
        'src/adapter.js'
      ]
    },
    build: {
      adapter: '<%= files.adapter %>'
    },
    eslint: {
      target: [
        '<%= files.adapter %>',
        '*.js',
        'lib/index.js',
        'tasks/*.js',
        'test/**/*.js'
      ]
    },
    karma: {
      adapter: {
        configFile: 'karma.conf.js',
        autoWatch: false,
        singleRun: true,
        reporters: ['dots']
      }
    },
    'npm-publish': {
      options: {
        requires: ['build']
      }
    },
    'npm-contributors': {
      options: {
        commitMessage: 'chore: update contributors'
      }
    },
    conventionalChangelog: {
      release: {
        options: {
          changelogOpts: {
            preset: 'angular'
          }
        },
        src: 'CHANGELOG.md'
      }
    },
    bump: {
      options: {
        commitFiles: [
          'package.json',
          'CHANGELOG.md'
        ],
        commitMessage: 'chore: release v%VERSION%',
        pushTo: 'upstream'
      }
    }
  })

  require('load-grunt-tasks')(grunt)
  grunt.loadTasks('tasks')
  grunt.registerTask('default', ['build', 'eslint', 'test'])
  grunt.registerTask('test', ['karma'])

  grunt.registerTask('release', 'Build, bump and publish to NPM.', function (type) {
    grunt.task.run([
      'npm-contributors',
      'bump:' + (type || 'patch') + ':bump-only',
      'build',
      'conventionalChangelog',
      'bump-commit',
      'npm-publish'
    ])
  })
}


================================================
FILE: karma.conf.js
================================================
module.exports = function (config) {
  config.set({
    frameworks: ['mocha', 'chai', 'sinon'],

    files: [
      'src/*.js',
      'test/src/*.js'
    ],

    browsers: process.env.TRAVIS ? ['Firefox'] : ['Chrome'],

    autoWatch: true,

    plugins: [
      require.resolve('./'),
      'karma-chai',
      'karma-sinon',
      'karma-firefox-launcher',
      'karma-chrome-launcher'
    ]
  })
}


================================================
FILE: lib/index.js
================================================
var path = require('path')
var extend = require('util')._extend
var minimist = require('minimist')

var createPattern = function (path) {
  return {pattern: path, included: true, served: true, watched: false}
}

var initMocha = function (files, config) {
  var mochaPath = path.dirname(require.resolve('mocha'))
  files.unshift(createPattern(path.join(__dirname, 'adapter.js')))

  config = config || {}
  config.client = config.client || {}
  var mochaConfig = config.client.mocha = getMochaOpts(config.client.mocha || {})

  if (mochaConfig.require && mochaConfig.require.map) {
    mochaConfig.require.map(function (requirePath) {
      return files.unshift(createPattern(requirePath))
    })
  }

  files.unshift(createPattern(path.join(mochaPath, 'mocha.js')))

  if (mochaConfig.reporter) {
    files.unshift(createPattern(path.join(mochaPath, 'mocha.css')))
  }
}

initMocha.$inject = ['config.files', 'config']

module.exports = {
  'framework:mocha': ['factory', initMocha]
}

function getMochaOpts (mochaConfig) {
  var optsPath = typeof mochaConfig.opts === 'string' ? mochaConfig.opts : 'test/mocha.opts'

  if (!mochaConfig.opts) {
    return mochaConfig
  }

  delete mochaConfig.opts

  var fs = require('fs')
  if (!fs.existsSync(optsPath)) {
    return mochaConfig
  }

  return extend(normalizeOpts(minimist(fs.readFileSync(optsPath, 'utf8')
    .replace(/\\\s/g, '%20')
    .split(/\s/)
    .filter(Boolean)
    .map(function (value) {
      return value.replace(/%20/g, ' ')
    }))), mochaConfig)

  function normalizeOpts (opts) {
    opts = [
      'require',

      'ui',
      'reporter',
      'globals',
      'grep',
      'timeout',
      'slow',
      'bail',
      'ignoreLeaks'
    ].reduce(function (result, optName) {
      if (opts.hasOwnProperty(optName)) {
        result[optName] = opts[optName]
      }

      return result
    }, {})

    opts.require = [].concat(opts.require || [])

    return opts
  }
}


================================================
FILE: package.json
================================================
{
  "name": "karma-mocha",
  "version": "2.0.1",
  "description": "A Karma plugin. Adapter for Mocha testing framework.",
  "main": "lib/index.js",
  "sharedKarmaFiles": {
    "editorconfig": ".editorconfig",
    "gitattributes": ".gitattributes"
  },
  "scripts": {
    "test": "grunt test",
    "test:lib": "mocha test/lib"
  },
  "repository": {
    "type": "git",
    "url": "git://github.com/karma-runner/karma-mocha.git"
  },
  "keywords": [
    "karma-plugin",
    "karma-adapter",
    "mocha"
  ],
  "author": "Vojta Jina <vojta.jina@gmail.com>",
  "dependencies": {
    "minimist": "^1.2.3"
  },
  "devDependencies": {
    "chai": "^3.4.1",
    "eslint": "^4.18.2",
    "eslint-config-standard": "^5.1.0",
    "eslint-plugin-promise": "^1.0.8",
    "eslint-plugin-react": "^5.2.2",
    "eslint-plugin-standard": "^1.3.2",
    "grunt": "~1.0",
    "grunt-auto-release": "~0.0.2",
    "grunt-bump": "~0.8.0",
    "grunt-conventional-changelog": "^6.0.1",
    "grunt-eslint": "^18.0.0",
    "grunt-karma": "2.x",
    "grunt-npm": "~0.0.2",
    "karma": "^1.0.0",
    "karma-chai": "^0.1.0",
    "karma-chrome-launcher": "^1.0.0",
    "karma-firefox-launcher": "^1.0.0",
    "karma-sinon": "^1.0.3",
    "load-grunt-tasks": "^3.2.0",
    "mocha": "^3.0.0",
    "mock-fs": "^4.10.1",
    "shared-karma-files": "git://github.com/karma-runner/shared-karma-files.git#82ae8d02",
    "sinon": "^1.17.2",
    "@semantic-release/changelog": "^3.0.6",
    "@semantic-release/git": "^7.0.18",
    "semantic-release": "^15.14.0",
    "@commitlint/cli": "^8.3.4",
    "@commitlint/config-conventional": "^8.3.4",
    "husky": "^4.0.3"
  },
  "husky": {
    "hooks": {
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }
  },
  "license": "MIT",
  "contributors": [
    "Maksim Ryzhikov <rv.maksim@gmail.com>",
    "Friedel Ziegelmayer <friedel.ziegelmayer@gmail.com>",
    "dignifiedquire <friedel.ziegelmayer@gmail.com>",
    "Jordan Klassen <jordan@vidigami.com>",
    "Martin Hansen <martin@martinhansen.no>",
    "Mark Ethan Trostler <mark@zzo.com>",
    "Dave Geddes <davidcgeddes@gmail.com>",
    "Aliaksei Shytkin <e79eas@gmail.com>",
    "Pawel Kozlowski <pkozlowski.opensource@gmail.com>",
    "Christopher Hiller <boneskull@boneskull.com>",
    "Lukasz Bandzarewicz <lucassus@gmail.com>",
    "Jonathan Knapp <jon@coffeeandcode.com>",
    "Karolis Narkevicius <karolis.n@gmail.com>",
    "Mark Trostler <mark@zzo.com>",
    "Peter Halliday <pghalliday@gmail.com>",
    "Raphael Luba <raphael@leanbyte.com>",
    "Sahat Yalkabov <sakhat@gmail.com>",
    "Tim Macfarlane <timmacfarlane@gmail.com>",
    "Vova Bilonenko <bilonenko.v@gmail.com>",
    "dej611 <marco@terraling.com>",
    "eiriksm <eirik@morland.no>",
    "patrick kettner <patrickkettner@gmail.com>",
    "Aymeric Beaumet <aymeric@beaumet.me>",
    "Christian Schlensker <christian@cswebartisan.com>",
    "Christian Schulze <christian.schulze@mywave.me>",
    "Ciro S. Costa <ciro.costa@usp.br>",
    "Dan Thareja <danthareja@gmail.com>",
    "Darryl Pogue <darryl@dpogue.ca>",
    "Darryl Pogue <dvpdiner2@gmail.com>",
    "JONATHAN PARK <jonathan@silvenstudios.com>",
    "James Morris <jamie@maloric.com>",
    "Jason Divock <jdivock@gmail.com>",
    "Jeff Jagoda <jeffrey.jagoda@gmail.com>"
  ]
}


================================================
FILE: release.config.js
================================================
module.exports = {
  debug: true,
  branch: 'master',
  verifyConditions: [
    '@semantic-release/changelog',
    '@semantic-release/npm',
    '@semantic-release/github'
  ],
  prepare: [
    '@semantic-release/changelog',
    '@semantic-release/npm',
    '@semantic-release/git'
  ],
  publish: [
    '@semantic-release/npm',
    '@semantic-release/github'
  ],
  success: [
    '@semantic-release/github'
  ]
}


================================================
FILE: src/adapter.js
================================================
// backwards compatible version of (Array|String).prototype.includes
var includes = function (collection, element, startIndex) {
  if (!collection || !collection.length) {
    return false
  }

  // strings support indexOf already
  if (typeof collection === 'string') {
    return collection.indexOf(element, startIndex) !== -1
  }

  if (Array.prototype.indexOf) {
    return collection.indexOf(element, startIndex) !== -1
  }

  for (var i = startIndex || 0, len = collection.length; i < len; i++) {
    if (collection[i] === element) {
      return true
    }
  }
}

// Date.now polyfill for IE <= 8
if (!Date.now) {
  Date.now = function () {
    return +new Date()
  }
}

var formatError = function (error) {
  var stack = error.stack
  var message = error.message

  if (stack) {
    if (message && !includes(stack, message)) {
      stack = message + '\n' + stack
    }

    // remove mocha stack entries
    return stack.replace(/\n.+\/mocha\/mocha\.js\?\w*:[\d:]+\)?(?=(\n|$))/g, '')
  }

  return message
}

var processAssertionError = function (error_) {
  var error

  if (window.Mocha && error_.hasOwnProperty('showDiff')) {
    error = {
      name: error_.name,
      message: error_.message,
      showDiff: error_.showDiff
    }

    if (error.showDiff) {
      error.actual = window.Mocha.utils.stringify(error_.actual)
      error.expected = window.Mocha.utils.stringify(error_.expected)
    }
  }

  return error
}

// non-compliant version of Array::reduce.call (requires memo argument)
var arrayReduce = function (array, reducer, memo) {
  for (var i = 0, len = array.length; i < len; i++) {
    memo = reducer(memo, array[i])
  }
  return memo
}

var createMochaReporterNode = function () {
  var mochaRunnerNode = document.createElement('div')
  mochaRunnerNode.setAttribute('id', 'mocha')
  document.body.appendChild(mochaRunnerNode)
}

var haveMochaConfig = function (karma) {
  return karma.config && karma.config.mocha
}

var reportTestResult = function (karma, test) {
  var skipped = test.pending === true

  var result = {
    id: '',
    description: test.title,
    suite: [],
    success: test.state === 'passed',
    skipped: skipped,
    pending: skipped,
    time: skipped ? 0 : test.duration,
    log: test.$errors || [],
    assertionErrors: test.$assertionErrors || [],
    startTime: test.$startTime,
    endTime: Date.now()
  }

  var pointer = test.parent
  while (!pointer.root) {
    result.suite.unshift(pointer.title)
    pointer = pointer.parent
  }

  if (haveMochaConfig(karma) && karma.config.mocha.expose && karma.config.mocha.expose.forEach) {
    result.mocha = {}
    karma.config.mocha.expose.forEach(function (prop) {
      if (test.hasOwnProperty(prop)) {
        result.mocha[prop] = test[prop]
      }
    })
  }

  karma.result(result)
}

var createMochaReporterConstructor = function (tc, pathname) {
  var isDebugPage = /debug.html$/.test(pathname)

  // Set custom reporter on debug page
  if (isDebugPage && haveMochaConfig(tc) && tc.config.mocha.reporter) {
    createMochaReporterNode()
    return tc.config.mocha.reporter
  }

  // TODO(vojta): error formatting
  return function (runner) {
    // runner events
    // - start
    // - end
    // - suite
    // - suite end
    // - test
    // - test end
    // - pass
    // - fail
    // - pending

    runner.on('start', function () {
      tc.info({total: runner.total})
    })

    runner.on('end', function () {
      tc.complete({
        coverage: window.__coverage__
      })
    })

    runner.on('test', function (test) {
      test.$startTime = Date.now()
      test.$errors = []
      test.$assertionErrors = []
    })

    runner.on('pending', function (test) {
      test.pending = true
    })

    runner.on('fail', function (test, error) {
      var simpleError = formatError(error)
      var assertionError = processAssertionError(error)

      if (test.type === 'hook') {
        test.$errors = isDebugPage ? [error] : [simpleError]
        test.$assertionErrors = assertionError ? [assertionError] : []
        reportTestResult(tc, test)
      } else {
        test.$errors.push(isDebugPage ? error : simpleError)
        if (assertionError) test.$assertionErrors.push(assertionError)
      }
    })

    runner.on('test end', function (test) {
      reportTestResult(tc, test)
    })
  }
}
/* eslint-disable no-unused-vars */
var createMochaStartFn = function (mocha) {
  /* eslint-enable no-unused-vars */
  return function (config) {
    var clientArguments
    config = config || {}
    clientArguments = config.args

    if (clientArguments) {
      if (Object.prototype.toString.call(clientArguments) === '[object Array]') {
        arrayReduce(clientArguments, function (isGrepArg, arg) {
          if (isGrepArg) {
            mocha.grep(new RegExp(arg))
          } else if (arg === '--grep') {
            return true
          } else {
            var match = /--grep=(.*)/.exec(arg)

            if (match) {
              mocha.grep(new RegExp(match[1]))
            }
          }
          return false
        }, false)
      }

      /**
       * TODO(maksimrv): remove when karma-grunt plugin will pass
       * clientArguments how Array
       */
      if (clientArguments.grep) {
        mocha.grep(clientArguments.grep)
      }
    }

    mocha.run()
  }
}

// Default configuration
var mochaConfig = {
  reporter: createMochaReporterConstructor(window.__karma__, window.location.pathname),
  ui: 'bdd',
  globals: ['__cov*']
}

// Pass options from client.mocha to mocha
/* eslint-disable no-unused-vars */
var createConfigObject = function (karma) {
  /* eslint-enable no-unused-vars */

  if (!karma.config || !karma.config.mocha) {
    return mochaConfig
  }

  // Copy all properties to mochaConfig
  for (var key in karma.config.mocha) {
    // except for reporter, require, or expose
    if (includes(['reporter', 'require', 'expose'], key)) {
      continue
    }

    // and merge the globals if they exist.
    if (key === 'globals') {
      mochaConfig.globals = mochaConfig.globals.concat(karma.config.mocha[key])
      continue
    }

    mochaConfig[key] = karma.config.mocha[key]
  }
  return mochaConfig
}


================================================
FILE: src/adapter.wrapper
================================================
;(function (window) {

%CONTENT%

  window.__karma__.start = createMochaStartFn(window.mocha)
  window.mocha.setup(createConfigObject(window.__karma__))
})(window)


================================================
FILE: tasks/build.js
================================================
module.exports = function (grunt) {
  /**
   * Build given file - wrap it with a function call
   * TODO(vojta): compile with uglify-js
   */
  grunt.registerMultiTask('build', 'Wrap given file into a function call.', function () {
    var src = grunt.file.expand(this.data).pop()
    var dest = src.replace('src/', 'lib/')
    var wrapper = src.replace('.js', '.wrapper')

    grunt.file.copy(wrapper, dest, {process: function (content) {
      var wrappers = content.split(/%CONTENT%\r?\n/)
      return wrappers[0] + grunt.file.read(src) + wrappers[1]
    }})

    grunt.log.ok('Created ' + dest)
  })
}


================================================
FILE: test/lib/.eslintrc
================================================
{
  "env": {
    "mocha": true
  }
}


================================================
FILE: test/lib/index.spec.js
================================================
var mock = require('mock-fs')
var expect = require('chai').expect
var initMocha = require('../../lib')['framework:mocha'][1]

describe('framework:mocha', function () {
  var files

  beforeEach(function () {
    files = createMockFiles()
  })

  it('should add adapter.js', function () {
    initMocha(files)

    expect(files[1].pattern).to.contain('adapter.js')
  })

  it('should add mocha.js', function () {
    initMocha(files)

    expect(files[0].pattern).to.contain('mocha.js')
  })

  it('should add required files', function () {
    var mochaConfig = {require: ['foo.js']}

    initMocha(files, createMochaConfig(mochaConfig))

    expect(files[1].pattern).to.contain('foo.js')
  })

  it('should add mocha.css if we define reporter in config', function () {
    var mochaConfig = {reporter: 'html'}

    initMocha(files, createMochaConfig(mochaConfig))

    expect(files[0].pattern).to.contain('mocha.css')
  })

  describe('load mocha.opts as a configuration file', function () {
    beforeEach(function () {
      mock({
        'test/mocha.opts': [
          '--sort',

          '--require should',
          '--reporter dot',
          '--ui bdd',
          '--globals foo',
          '--globals bar',
          '--timeout 100',
          '--slow 200',
          '--grep zoo',
          '--bail',
          '--ignoreLeaks'
        ].join('\n'),
        'test/foo.opts': '--ui tdd'
      })
    })

    afterEach(function () {
      mock.restore()
    })

    it('should read mocha options from test/mocha.opts file by default', function () {
      var config = createMochaConfig({opts: true})

      initMocha(files, config)

      expect(config.client.mocha.require).to.eql(['should'])
      expect(config.client.mocha.globals).to.eql(['foo', 'bar'])
      expect(config.client.mocha.reporter).to.equal('dot')
      expect(config.client.mocha.ui).to.equal('bdd')
    })

    it('should set only supported options', function () {
      var config = createMochaConfig({opts: true})

      initMocha(files, config)

      expect(config.client.mocha).to.eql({
        require: ['should'],

        ui: 'bdd',
        reporter: 'dot',
        globals: ['foo', 'bar'],
        grep: 'zoo',

        timeout: 100,
        slow: 200,
        bail: true,
        ignoreLeaks: true
      })
    })

    it('should rewrite options from mocha.opts by options from config', function () {
      var config = createMochaConfig({opts: true, ui: 'tdd', globals: ['zoo']})

      initMocha(files, config)

      expect(config.client.mocha.require).to.eql(['should'])
      expect(config.client.mocha.globals).to.eql(['zoo'])
      expect(config.client.mocha.reporter).to.equal('dot')
      expect(config.client.mocha.ui).to.equal('tdd')
    })

    it('should pass custom mocha.opts path', function () {
      var config = createMochaConfig({opts: 'test/foo.opts'})

      initMocha(files, config)

      expect(config.client.mocha.ui).to.equal('tdd')
    })
  })
})

function createMockFiles () {
  return []
}

function createMochaConfig (mochaConfig) {
  return {
    client: {
      mocha: mochaConfig
    }
  }
}


================================================
FILE: test/src/.eslintrc
================================================
{
  "env": {
    "mocha": true,
    "browser": true
  },
  "globals": {
    "expect": true,
    "MockSocket": true,
    "sinon": true,
    "Emitter": true,
    "formatError": true
  }
}


================================================
FILE: test/src/adapter.spec.js
================================================
/**
 Tests for adapter/mocha.src.js
 These tests are executed in browser.
 */

/* globals
 createMochaReporterConstructor,
 createMochaReporterNode,
 createMochaStartFn,
 createConfigObject,
 mochaConfig: true,
 formatError: true,
 processAssertionError: true,
 MockSocket: true,
 Emitter: true,
 sinon: true,
 expect: true,
 describe: true,
 beforeEach: true,
 afterEach: true,
 it: true
 */
describe('adapter mocha', function () {
  var Karma = window.__karma__.constructor
  var sandbox

  beforeEach(function () {
    sandbox = sinon.sandbox.create()
  })

  afterEach(function () {
    sandbox.restore()
  })

  describe('createMochaReporterConstructor', function () {
    beforeEach(function () {
      this.karma = new Karma(function (method, args) { })
      this.karma.config = {
        mocha: {
          reporter: 'html'
        }
      }

      sandbox.stub(window, 'createMochaReporterNode')
    })

    it('should take reporter from client config on debug page', function () {
      expect(createMochaReporterConstructor(this.karma, '/debug.html')).to.equal('html')
    })

    it('should create node for mocha reporter', function () {
      createMochaReporterConstructor(this.karma, '/debug.html')

      expect(createMochaReporterNode.called).to.equal(true)
    })

    it('should define console reporter if does not pass reporter in config', function () {
      this.karma.config.mocha.reporter = null

      expect(createMochaReporterConstructor(this.karma, '/debug.html')).not.to.equal(null)
    })
  })

  describe('reporter', function () {
    var runner, tc

    beforeEach(function () {
      tc = new Karma(function (method, args) { })
      runner = new Emitter()
      var reporter = new (createMochaReporterConstructor(tc))(runner) // eslint-disable-line
    })

    describe('start', function () {
      it('should report total number of specs', function () {
        runner.total = 12
        sandbox.spy(tc, 'info')

        runner.emit('start')
        expect(tc.info.getCall(0).args).to.deep.eq([{total: 12}])
      })
    })

    describe('end', function () {
      it('should report complete', function () {
        sandbox.spy(tc, 'complete')

        runner.emit('end')
        expect(tc.complete.called).to.eq(true)
      })
    })

    describe('test end', function () {
      it('should report result', function () {
        var beforeStartTime = Date.now()
        var DURATION = 200

        sandbox.stub(tc, 'result', function (result) {
          var afterEndTime = Date.now()
          expect(result.id).to.not.be.undefined
          expect(result.description).to.eq('should do something')
          expect(result.suite instanceof Array).to.eq(true)
          expect(result.success).to.eq(true)
          expect(result.skipped).to.to.eql(false)
          expect(result.pending).to.to.eql(false)
          expect(result.log instanceof Array).to.eq(true)
          expect(result.assertionErrors instanceof Array).to.eq(true)
          expect(result.startTime).to.be.at.least(beforeStartTime)
          expect(result.endTime - result.startTime).to.be.at.least(DURATION)
          expect(result.endTime).to.be.at.most(afterEndTime)
          expect(result.time).to.eq(DURATION)
        })

        var mockMochaResult = {
          duration: DURATION,
          parent: {title: 'desc2', parent: {title: 'desc1', root: true}, root: false},
          state: 'passed',
          title: 'should do something'
        }

        runner.emit('test', mockMochaResult)
        // wait at least 200ms to get different start and end times
        var afterStartTime = Date.now()
        while (Date.now() - afterStartTime < DURATION) {}
        runner.emit('test end', mockMochaResult)

        expect(tc.result.called).to.eq(true)
      })

      it('should report skipped result', function () {
        sandbox.stub(tc, 'result', function (result) {
          expect(result.skipped).to.eq(true)
          expect(result.pending).to.eq(true)
        })

        var mockMochaResult = {
          parent: {root: true}
        }

        runner.emit('pending', mockMochaResult)
        runner.emit('test end', mockMochaResult)

        expect(tc.result.called).to.eq(true)
      })

      it('should report time 0 for skipped tests', function () {
        sandbox.stub(tc, 'result', function (result) {
          expect(result.skipped).to.eq(true)
          expect(result.time).to.eq(0)
        })

        var mockMochaResult = {
          pending: true,
          parent: {root: true}
        }

        runner.emit('test', mockMochaResult)
        runner.emit('test end', mockMochaResult)

        expect(tc.result.called).to.eq(true)
      })

      it('should report failed result', function () {
        sandbox.stub(tc, 'result', function (result) {
          expect(result.success).to.to.eql(false)
          expect(result.skipped).to.to.eql(false)
          expect(result.log).to.deep.eq(['Big trouble.', 'Another fail.'])
          expect(result.assertionErrors).to.be.empty
        })

        var mockMochaResult = {
          parent: {title: 'desc2', root: true},
          state: 'failed',
          title: 'should do something'
        }

        runner.emit('test', mockMochaResult)
        runner.emit('fail', mockMochaResult, {message: 'Big trouble.'})
        runner.emit('pass', mockMochaResult)
        runner.emit('fail', mockMochaResult, {message: 'Another fail.'})
        runner.emit('test end', mockMochaResult)

        expect(tc.result.called).to.eq(true)
      })

      it('should report failed mocha result', function () {
        sandbox.stub(tc, 'result', function (result) {
          expect(result.log).to.deep.eq(['Big trouble.', 'Another fail.'])
          expect(result.assertionErrors).to.deep.eq([{
            name: 'AssertionError',
            message: 'Big trouble.',
            showDiff: false
          }])
        })

        var mockMochaResult = {
          parent: {title: 'desc2', root: true},
          state: 'failed',
          title: 'should do something'
        }

        runner.emit('test', mockMochaResult)
        runner.emit('fail', mockMochaResult, {
          name: 'AssertionError',
          message: 'Big trouble.',
          showDiff: false,
          actual: 1,
          expected: 2
        })
        runner.emit('fail', mockMochaResult, {message: 'Another fail.'})
        runner.emit('test end', mockMochaResult)

        expect(tc.result.called).to.eq(true)
      })

      it('should report suites', function () {
        sandbox.stub(tc, 'result', function (result) {
          expect(result.suite).to.deep.eq(['desc1', 'desc2'])
        })

        var mockMochaResult = {
          parent: {title: 'desc2', parent: {title: 'desc1', parent: {root: true}, root: false}, root: false},
          title: 'should do something'
        }

        runner.emit('test', mockMochaResult)
        runner.emit('test end', mockMochaResult)

        expect(tc.result.called).to.eq(true)
      })

      it('should report mocha properties through the `expose` option', function () {
        tc.config = {
          mocha: {
            expose: ['body', 'hello']
          }
        }

        sandbox.stub(tc, 'result', function (result) {
          expect(result.mocha.body).to.eq('function(){ expect(false).to.be(true) }')
          expect(result.mocha.hello).to.eq('world')
        })

        var mockMochaResult = {
          parent: {title: 'desc2', root: true},
          title: 'should do something',
          body: 'function(){ expect(false).to.be(true) }',
          hello: 'world'
        }

        runner.emit('test end', mockMochaResult)

        expect(tc.result.called).to.eq(true)
      })

      it('should not report mocha properties if `expose` is not configured', function () {
        sandbox.stub(tc, 'result', function (result) {
          expect(result.mocha).to.not.exist
        })

        var mockMochaResult = {
          parent: {title: 'desc2', root: true},
          title: 'should do something',
          body: 'function(){ expect(false).to.be(true) }',
          hello: 'world'
        }

        runner.emit('test end', mockMochaResult)

        expect(tc.result.called).to.eq(true)
      })
    })

    describe('fail', function () {
      it('should end test on hook failure', function () {
        sandbox.stub(tc, 'result', function (result) {
          expect(result.success).to.to.eql(false)
          expect(result.skipped).to.to.eql(false)
          expect(result.log).to.deep.eq(['hook failed'])
        })

        var mockMochaHook = {
          type: 'hook',
          title: 'scenario "before each" hook',
          parent: {title: 'desc1', root: true}
        }

        runner.emit('hook', mockMochaHook)
        runner.emit('fail', mockMochaHook, {message: 'hook failed'})

        expect(tc.result.called).to.eq(true)
      })

      it('should not emit test end on hook failure', function () {
        const testEndStub = sandbox.stub()
        runner.on('test end', testEndStub)

        var mockMochaHook = {
          type: 'hook',
          title: 'scenario "before each" hook',
          parent: {title: 'desc1', root: true}
        }

        runner.emit('hook', mockMochaHook)
        runner.emit('fail', mockMochaHook, {message: 'hook failed'})
        expect(testEndStub.called).to.eq(false)
      })

      it('should end the test only once on uncaught exceptions', function () {
        sandbox.stub(tc, 'result', function (result) {
          expect(result.success).to.to.eql(false)
          expect(result.skipped).to.to.eql(false)
          expect(result.log).to.deep.eq(['Uncaught error.'])
        })

        var mockMochaResult = {
          parent: {title: 'desc2', root: true},
          state: 'failed',
          title: 'should do something'
        }

        runner.emit('test', mockMochaResult)
        runner.emit('fail', mockMochaResult, {message: 'Uncaught error.', uncaught: true})
        runner.emit('test end', mockMochaResult)

        expect(tc.result.called).to.eq(true)
      })

      it('should remove mocha stack entries', function () {
        sandbox.stub(tc, 'result', function (result) {
          var log = result.log[0]
          expect(log).to.not.contain('/mocha/mocha.js')
          expect(log).to.contain('/spec/controllers/list/formCtrlSpec.js')
        })

        var mockMochaResult = {
          parent: {root: true}
        }

        var stack =
          'at $httpBackend (http://localhost:8080/base/app/bower_components/angular-mocks/angular-mocks.js?506e0a37bcd764ec63da3fd7005bf56592b3df32:1149)\n' +
          'at sendReq (http://localhost:8080/base/app/bower_components/angular/angular.js?7deca05396a4331b08f812e4962ef9df1d9de0b5:8408)\n' +
          'at http://localhost:8080/base/app/bower_components/angular/angular.js?7deca05396a4331b08f812e4962ef9df1d9de0b5:8125\n' +
          'at http://localhost:8080/base/test/client/spec/controllers/list/formCtrlSpec.js?67eaca0f801cf45a86802a262618a6cfdc6a47be:110\n' +
          'at invoke (http://localhost:8080/base/app/bower_components/angular/angular.js?7deca05396a4331b08f812e4962ef9df1d9de0b5:4068)\n' +
          '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?529c1ea3966a13c21efca5afe9a2317dafcd8abc:4338)\n' +
          'at http://localhost:8080/base/node_modules/mocha/mocha.js?529c1ea3966a13c21efca5afe9a2317dafcd8abc:4331\n' +
          'at next (http://localhost:8080/base/node_modules/mocha/mocha.js?529c1ea3966a13c21efca5afe9a2317dafcd8abc:4653)\n' +
          'at http://localhost:8080/base/node_modules/mocha/mocha.js?529c1ea3966a13c21efca5afe9a2317dafcd8abc:4663\n' +
          'at next (http://localhost:8080/base/node_modules/mocha/mocha.js?529c1ea3966a13c21efca5afe9a2317dafcd8abc:4601)\n'

        runner.emit('test', mockMochaResult)
        runner.emit('fail', mockMochaResult, {message: 'Another fail.', stack: stack})
        runner.emit('test end', mockMochaResult)

        expect(tc.result.called).to.eq(true)
      })

      it('should not remove escaped strings containing mocha stack entries', function () {
        sandbox.stub(tc, 'result', function (result) {
          var log = result.log[0]
          expect(log).to.contain('something important that contains an escaped mocha stack trace')
        })

        var mockMochaResult = {
          parent: {root: true}
        }

        var stack =
          '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' +
          'at $httpBackend (http://localhost:8080/base/app/bower_components/angular-mocks/angular-mocks.js?506e0a37bcd764ec63da3fd7005bf56592b3df32:1149)\n' +
          'at sendReq (http://localhost:8080/base/app/bower_components/angular/angular.js?7deca05396a4331b08f812e4962ef9df1d9de0b5:8408)\n' +
          'at http://localhost:8080/base/app/bower_components/angular/angular.js?7deca05396a4331b08f812e4962ef9df1d9de0b5:8125\n' +
          'at http://localhost:8080/base/test/client/spec/controllers/list/formCtrlSpec.js?67eaca0f801cf45a86802a262618a6cfdc6a47be:110\n' +
          'at invoke (http://localhost:8080/base/app/bower_components/angular/angular.js?7deca05396a4331b08f812e4962ef9df1d9de0b5:4068)\n' +
          '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?529c1ea3966a13c21efca5afe9a2317dafcd8abc:4338)\n' +
          'at http://localhost:8080/base/node_modules/mocha/mocha.js?529c1ea3966a13c21efca5afe9a2317dafcd8abc:4331\n' +
          'at next (http://localhost:8080/base/node_modules/mocha/mocha.js?529c1ea3966a13c21efca5afe9a2317dafcd8abc:4653)\n' +
          'at http://localhost:8080/base/node_modules/mocha/mocha.js?529c1ea3966a13c21efca5afe9a2317dafcd8abc:4663\n' +
          'at next (http://localhost:8080/base/node_modules/mocha/mocha.js?529c1ea3966a13c21efca5afe9a2317dafcd8abc:4601)\n'

        runner.emit('test', mockMochaResult)
        runner.emit('fail', mockMochaResult, {message: 'Another fail.', stack: stack})
        runner.emit('test end', mockMochaResult)

        expect(tc.result.called).to.eq(true)
      })
    })
  })

  describe('createMochaStartFn', function () {
    beforeEach(function () {
      this.mockMocha = {
        grep: function () {
        },
        run: function () {
        }
      }
    })

    it('should pass grep argument to mocha', function () {
      sandbox.spy(this.mockMocha, 'grep')

      createMochaStartFn(this.mockMocha)({
        args: ['--grep', 'test test']
      })

      expect(this.mockMocha.grep.getCall(0).args).to.deep.eq([/test test/])
    })

    it('should pass grep argument to mocha if we called the run with --grep=xxx', function () {
      sandbox.spy(this.mockMocha, 'grep')

      createMochaStartFn(this.mockMocha)({
        args: ['--grep=test test']
      })

      expect(this.mockMocha.grep.getCall(0).args).to.deep.eq([/test test/])
    })

    it('should pass grep argument to mocha if config.args contains property grep', function () {
      sandbox.spy(this.mockMocha, 'grep')

      createMochaStartFn(this.mockMocha)({
        args: {
          grep: 'test'
        }
      })

      expect(this.mockMocha.grep.getCall(0).args).to.deep.eq(['test'])
    })

    it('should not require client arguments', function () {
      var that = this

      expect(function () {
        createMochaStartFn(that.mockMocha)({})
      }).to.not.throw()
    })
  })

  describe('createConfigObject', function () {
    beforeEach(function () {
      this.originalMochaConfig = mochaConfig

      mochaConfig = {
        ui: 'bdd',
        globals: ['__cov']
      }

      this.karma = new Karma(new MockSocket(), null, null, null, {search: ''})
      this.karma.config = {}
    })

    afterEach(function () {
      mochaConfig = this.originalMochaConfig
    })

    it('should return default config if karma does not define client config', function () {
      this.karma.config = null

      expect(createConfigObject(this.karma)).to.eq(mochaConfig)
    })

    it('should return default config if the client config havent properties mocha', function () {
      expect(createConfigObject(this.karma)).to.eq(mochaConfig)
    })

    it('should pass client.mocha options to mocha config', function () {
      this.karma.config.mocha = {
        slow: 10
      }

      expect(createConfigObject(this.karma).slow).to.eq(10)
    })

    it('should rewrite ui options from default config', function () {
      this.karma.config.mocha = {
        ui: 'tdd'
      }

      expect(createConfigObject(this.karma).ui).to.eq('tdd')
    })

    it('should ignore propertie reporter from client config', function () {
      this.karma.config.mocha = {
        reporter: 'test'
      }

      expect(createConfigObject(this.karma).reporter).not.to.eq('test')
    })

    it('should ignore property require from client config', function () {
      this.karma.config.mocha = {
        require: 'test'
      }

      expect(createConfigObject(this.karma).require).not.to.eq('test')
    })

    it('should ignore property expose from client config', function () {
      this.karma.config.mocha = {
        expose: 'body'
      }

      expect(createConfigObject(this.karma).expose).not.to.eq('body')
    })

    it('should merge the globals from client config if they exist', function () {
      this.karma.config.mocha = {
        globals: ['test']
      }

      expect(createConfigObject(this.karma).globals).to.deep.eq(['__cov', 'test'])
    })
  })

  describe('formatError', function () {
    it('should properly format exceptions that contains \n in their message', function () {
      var errLines = formatError(new Error('foo\nbar')).split('\n')
      expect(errLines[0]).to.contain('foo')
      expect(errLines[1]).to.equal('bar')
      expect(errLines[2]).to.not.contain('foo')
    })
  })

  describe('processAssertionError', function () {
    it('should create object from mocha error', function () {
      var err = new Error()
      err.name = 'AssertionError'
      err.message = 'expected \'something\' to deeply equal \'something else\''
      err.showDiff = true
      err.actual = {baz: 'baz', foo: null, bar: function () {}}
      err.expected = {baz: 42, foo: undefined}

      var error = processAssertionError(err)

      expect(Object.keys(error)).to.be.eql(['name', 'message', 'showDiff', 'actual', 'expected'])
      expect(error.name).to.equal('AssertionError')
      expect(error.message).to.equal('expected \'something\' to deeply equal \'something else\'')
      expect(error.showDiff).to.be.true
      expect(error.actual).to.equal('{\n  "bar": [Function]\n  "baz": "baz"\n  "foo": [null]\n}')
      expect(error.expected).to.equal('{\n  "baz": 42\n  "foo": [undefined]\n}')
    })

    it('should not create object from simple error', function () {
      var err = new Error('Something wrong')

      var error = processAssertionError(err)

      expect(error).to.be.undefined
    })

    it('should not pass actual and expected if showDiff is off', function () {
      var err = new Error()
      err.message = 'expected \'something\' to deeply equal \'something else\''
      err.showDiff = false
      err.actual = {baz: 'baz', foo: null, bar: function () {}}
      err.expected = {baz: 42, foo: undefined}

      var error = processAssertionError(err)

      expect(Object.keys(error)).to.be.eql(['name', 'message', 'showDiff'])
      expect(error.name).to.equal('Error')
      expect(error.message).to.equal('expected \'something\' to deeply equal \'something else\'')
      expect(error.showDiff).to.be.false
      expect(error).to.not.have.property('actual')
      expect(error).to.not.have.property('expected')
    })
  })
})


================================================
FILE: test/src/mocks.js
================================================
var Emitter = function () {
  var listeners = {}

  this.on = function (event, fn) {
    if (!listeners[event]) {
      listeners[event] = []
    }

    listeners[event].push(fn)
  }

  this.emit = function (event) {
    var eventListeners = listeners[event]

    if (!eventListeners) return

    var i = 0
    while (i < eventListeners.length) {
      eventListeners[i].apply(null, Array.prototype.slice.call(arguments, 1))
      i++
    }
  }
}

var MockSocket = Emitter // eslint-disable-line no-unused-vars


================================================
FILE: wallaby.js
================================================
module.exports = function () {
  return {
    files: [
      'lib/**/*@(.js)'
    ],

    tests: [
      './test/lib/**/*.spec@(.js)'
    ],

    env: {
      type: 'node'
    },

    testFramework: 'mocha'
  }
}
Download .txt
gitextract_w97345x5/

├── .eslintrc
├── .gitignore
├── .mailmap
├── .npmignore
├── .travis.yml
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── commitlint.config.js
├── gruntfile.js
├── karma.conf.js
├── lib/
│   └── index.js
├── package.json
├── release.config.js
├── src/
│   ├── adapter.js
│   └── adapter.wrapper
├── tasks/
│   └── build.js
├── test/
│   ├── lib/
│   │   ├── .eslintrc
│   │   └── index.spec.js
│   └── src/
│       ├── .eslintrc
│       ├── adapter.spec.js
│       └── mocks.js
└── wallaby.js
Download .txt
SYMBOL INDEX (3 symbols across 2 files)

FILE: lib/index.js
  function getMochaOpts (line 36) | function getMochaOpts (mochaConfig) {

FILE: test/lib/index.spec.js
  function createMockFiles (line 117) | function createMockFiles () {
  function createMochaConfig (line 121) | function createMochaConfig (mochaConfig) {
Condensed preview — 24 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (57K chars).
[
  {
    "path": ".eslintrc",
    "chars": 27,
    "preview": "{\n  \"extends\": \"standard\"\n}"
  },
  {
    "path": ".gitignore",
    "chars": 48,
    "preview": "lib/adapter.js\nnode_modules\nnpm-debug.log\n.idea\n"
  },
  {
    "path": ".mailmap",
    "chars": 143,
    "preview": "<bitwiseman@gmail.com> <lnewman@book.com>\n<vojta.jina@gmail.com> <vojta@google.com>\n<friedel.ziegelmayer@gmail.com> <dig"
  },
  {
    "path": ".npmignore",
    "chars": 105,
    "preview": ".gitignore\n.travis.yml\nsrc\ntest\ntasks\n\nGruntfile.coffee\nkarma.conf.js\nkarma-v0.8.conf.js\nCONTRIBUTING.md\n"
  },
  {
    "path": ".travis.yml",
    "chars": 862,
    "preview": "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"
  },
  {
    "path": "CHANGELOG.md",
    "chars": 7354,
    "preview": "## [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:*"
  },
  {
    "path": "CONTRIBUTING.md",
    "chars": 186,
    "preview": "Please see the [Contributing to Karma] guide for information on contributing to this project.\n\n[Contributing to Karma]: "
  },
  {
    "path": "LICENSE",
    "chars": 1077,
    "preview": "The MIT License\n\nCopyright (C) 2011-2013 Google, Inc.\n\nPermission is hereby granted, free of charge, to any person obtai"
  },
  {
    "path": "README.md",
    "chars": 4682,
    "preview": "# karma-mocha\n\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-squar"
  },
  {
    "path": "commitlint.config.js",
    "chars": 64,
    "preview": "module.exports = {extends: ['@commitlint/config-conventional']}\n"
  },
  {
    "path": "gruntfile.js",
    "chars": 1578,
    "preview": "module.exports = function (grunt) {\n  grunt.initConfig({\n    pkgFile: 'package.json',\n    files: {\n      adapter: [\n    "
  },
  {
    "path": "karma.conf.js",
    "chars": 402,
    "preview": "module.exports = function (config) {\n  config.set({\n    frameworks: ['mocha', 'chai', 'sinon'],\n\n    files: [\n      'src"
  },
  {
    "path": "lib/index.js",
    "chars": 1947,
    "preview": "var path = require('path')\nvar extend = require('util')._extend\nvar minimist = require('minimist')\n\nvar createPattern = "
  },
  {
    "path": "package.json",
    "chars": 3274,
    "preview": "{\n  \"name\": \"karma-mocha\",\n  \"version\": \"2.0.1\",\n  \"description\": \"A Karma plugin. Adapter for Mocha testing framework.\""
  },
  {
    "path": "release.config.js",
    "chars": 414,
    "preview": "module.exports = {\n  debug: true,\n  branch: 'master',\n  verifyConditions: [\n    '@semantic-release/changelog',\n    '@sem"
  },
  {
    "path": "src/adapter.js",
    "chars": 6182,
    "preview": "// backwards compatible version of (Array|String).prototype.includes\nvar includes = function (collection, element, start"
  },
  {
    "path": "src/adapter.wrapper",
    "chars": 164,
    "preview": ";(function (window) {\n\n%CONTENT%\n\n  window.__karma__.start = createMochaStartFn(window.mocha)\n  window.mocha.setup(creat"
  },
  {
    "path": "tasks/build.js",
    "chars": 607,
    "preview": "module.exports = function (grunt) {\n  /**\n   * Build given file - wrap it with a function call\n   * TODO(vojta): compile"
  },
  {
    "path": "test/lib/.eslintrc",
    "chars": 37,
    "preview": "{\n  \"env\": {\n    \"mocha\": true\n  }\n}\n"
  },
  {
    "path": "test/lib/index.spec.js",
    "chars": 3118,
    "preview": "var mock = require('mock-fs')\nvar expect = require('chai').expect\nvar initMocha = require('../../lib')['framework:mocha'"
  },
  {
    "path": "test/src/.eslintrc",
    "chars": 186,
    "preview": "{\n  \"env\": {\n    \"mocha\": true,\n    \"browser\": true\n  },\n  \"globals\": {\n    \"expect\": true,\n    \"MockSocket\": true,\n    "
  },
  {
    "path": "test/src/adapter.spec.js",
    "chars": 20351,
    "preview": "/**\n Tests for adapter/mocha.src.js\n These tests are executed in browser.\n */\n\n/* globals\n createMochaReporterConstructo"
  },
  {
    "path": "test/src/mocks.js",
    "chars": 511,
    "preview": "var Emitter = function () {\n  var listeners = {}\n\n  this.on = function (event, fn) {\n    if (!listeners[event]) {\n      "
  },
  {
    "path": "wallaby.js",
    "chars": 213,
    "preview": "module.exports = function () {\n  return {\n    files: [\n      'lib/**/*@(.js)'\n    ],\n\n    tests: [\n      './test/lib/**/"
  }
]

About this extraction

This page contains the full source code of the karma-runner/karma-mocha GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 24 files (52.3 KB), approximately 15.4k tokens, and a symbol index with 3 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!