Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Mocha.opts not working as expected with client config #177

Open
nickytonline opened this issue Apr 20, 2017 · 1 comment
Open

Mocha.opts not working as expected with client config #177

nickytonline opened this issue Apr 20, 2017 · 1 comment

Comments

@nickytonline
Copy link

nickytonline commented Apr 20, 2017

Hi, I'm just wondering about mocha.opts. I know it is now supported via

{
   ...
   client: {
      mocha: {
         opts: './path-to-mocha-opts'
      }
   }
...
}

Here's the setup we have:

mocha.opts file contents:

--require babel-core/register
src/**/*.spec.js

here's the karma.conf file:

module.exports = function(config) {
  'use strict';
  config.set({

    basePath: '',
    port: 9880,
    colors: true,
    autoWatch: true,
    singleRun: true,
    browserDisconnectTimeout: 15000,
    browserNoActivityTimeout: 15000,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR ||
    //   config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    browsers: ['PhantomJS']
  });
};

and we extend it in gulp like so:

{
  configFile: __dirname + '/../karma.conf.js',
  frameworks: ['mocha', 'sinon-chai'],
  client: {
    useIframe: true,
    mocha: {
      opts: __dirname + '/../mocha.opts'
    }
  },
  singleRun: !isWatchmode
}

and here's our console output:

20 04 2017 13:57:39.644:WARN [watcher]: Pattern "babel-core/register" does not match any file.
20 04 2017 13:57:39.697:WARN [karma]: No captured browser, open http://localhost:9880/
20 04 2017 13:57:39.710:WARN [karma]: Port 9880 in use
20 04 2017 13:57:39.711:WARN [karma]: Port 9881 in use

With this configuration I am able to load the mocha.opts file, but when it gets parsed, it thinks that the require option is the file glob instead of it being the babel compiler. I know the configuration is correct because when I run node_module/.bin/mocha --opts ./path-to-mocha-opts, it runs fine.

Is there something different I should be doing in the config or my mocha.opts file?

@NullVoxPopuli
Copy link

I'd also love an answer to this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants