Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect the Grunt way of defining files #126

Open
NicBright opened this issue Oct 2, 2014 · 4 comments
Open

Respect the Grunt way of defining files #126

NicBright opened this issue Oct 2, 2014 · 4 comments

Comments

@NicBright
Copy link
Contributor

Right now, grunt-karma needs a dedicated "files" property in the options config object, e.g.

{ "karma": {
    "options": {
      "files": ["put-files-here"]
}}}

It is not possible to use the Grunt way of defining files http://gruntjs.com/configuring-tasks#files.
But it should, as grunt-karma is a Grunt plugin, after all.

@beckyconning
Copy link

Does this way of defining files cause this warning:

Warning: Object false has no method 'indexOf' Use --force to continue.

for anyone else when using the -v option?

@beckyconning
Copy link

This definitely causes the issue I mentioned above. This is a bug and should be raised as such.

To workaround place your files in an karma.conf.js file.

@deckar01
Copy link

This is a blocker for me right now. I need all of my child configs to inherit the files definition that tells the server to serve my html fixtures, but currently I only have access to grunt style file definitions in the child sections, so I have to repeat the entry in each one.

An options key name something like gruntFiles would solve my use case.

Using files differently between the options and the child configs was definitely a stumbling block for picking up grunt-karma. It would be nice if the karma style file lists used the files key in the child configs, and a different name was used for this grunt specific functionality.

@deckar01
Copy link

I created a helper that treats all the files properties as karma style files. It uses a separate key called gruntFiles for the grunt style files.

const gruntFiles = config.options.gruntFiles || [];
for(let key in config) {
  if(key === 'options') continue;
  const files = [{src: config[key].files || []}];
  const extraGruntFiles = config[key].gruntFiles || [];
  config[key].files = gruntFiles.concat(extraGruntFiles, files);
}

I think my config makes a little more sense now.

{
  options: {
    files: ['foo.js'],
    gruntFiles: [{src: ['fixtures/*.html'], served: true, included: false}]
  },
  unit1: {
    files: ['blah1.js', 'blah1.spec.js'],
  },
  unit2: {
    files: ['blah2.js'],
    gruntFiles: [{pattern: 'blah2.*.spec.js'}]
  }
}

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

No branches or pull requests

3 participants