Closed lautarobock closed 6 years ago
I have run into a similar issue.
It is broken because grunt-karma
no longer flattens the data.files
property.
Re-inserting the flatten resolves the issue, but I do not know the circumstances behind why it was removed.
Care to weigh in @jpommerening , @Dignifiedquire?
Hey there, thanks for the @mention, I'm always happy to clean up the mess I cause, haha.
The idea was for grunt-karma
to behave a little more like (most) other Grunt plugins, not to break existing functionality.
There were however sooo many possible configs, some possibly broke.
@Dignifiedquire already fixed some them (#134, #135, sorry for causing this!), but probably missed this one.
Let me explain:
Karma is a "multi-task". As such its configuration is split into multiple targets. For example karma.unit
and karma.e2e
. Each target can have its own .options
. All these options inherit from karma.options
, kind of like "global" options.
To make matters worse, Grunt usually expects files besides the options
, not inside.
So, to keep it short, there's a hell of a lot places you can place files here, some of them work, some don't. Try this:
karma: {
/* call karma:myTaskTarget, or use something else */
myTaskTarget: {
files: {
src: [
'<%= prj.files.src %>',
'<%= prj.files.srcTest %>'
]
}
}
}
Thanks @jpommerening !! but is not working
WARN [config]: Invalid pattern [object Object]!
Object is missing "pattern" property.
I've create a repo with bug reproduction. please try to reproduce it, will take a few minutes Repo: https://github.com/lautarobock/bug-grunt-karma In README.md define steps for reproduction
Thanks!
Hey @lautarobock, based on the feedback from @jpommerening, I was able to resolve my issue.
Based on your github repo example, I suspect the following would resolve your issue:
karma: {
options: {
frameworks: ['jasmine'],
browsers: ['PhantomJS'],
plugins: [
'karma-jasmine',
'karma-phantomjs-launcher'
],
singleRun: true
},
build: {
files: {
src: [
'<%= prj.dependencies %>',
'<%= prj.devDependencies %>',
'<%= prj.files.src %>',
'<%= prj.files.srcTest %>'
]
}
}
}
mmm.... yes, it work, but I need to put files
inside of karma.options
for sharing between different subtask.
in my real scenario I have 2 different which share same files
karma: {
options: {
files: [
'<%= prj.files.src %>',
'<%= prj.files.srcTest %>'
]
},
build {
//config for build
},
release: {
//other config for release
}
}
I have the same setup actually. I did something like this:
karma: {
options: {
frameworks: ['jasmine'],
browsers: ['PhantomJS'],
plugins: [
'karma-jasmine',
'karma-phantomjs-launcher'
],
singleRun: true
},
build: {
files: {
src: [
'<%= prj.dependencies %>',
'<%= prj.devDependencies %>',
'<%= prj.files.src %>',
'<%= prj.files.srcTest %>'
]
}
},
release: {
files: '<%= karma.build.files %>'
}
}
Great! thanks!
(Triaging issues with more than a year of inactivity)
The flattening of files was fixed in https://github.com/karma-runner/grunt-karma/pull/150 and furher tested and improved with https://github.com/karma-runner/grunt-karma/pull/262 andd https://github.com/karma-runner/grunt-karma/pull/263.
If you experience a problem with the current version, please report it as a new issue.
It there any change of the way to load files in karma.options.files property from version 0.9.x to 0.10.x?
in 0.9.x I have this code and works fine
but in 0.10.1 give me this error
For fixing I have to change
And it works! but, How can include in
karma.options.files
an array of patterns like in first example?