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

preprocessors.shift(...) is not a function #1521

Comments

@kentcdodds
Copy link
Contributor

I think this commit is giving me this error:

27 07 2015 15:21:53.351:ERROR [karma]: [TypeError: preprocessors.shift(...) is not a function]
TypeError: preprocessors.shift(...) is not a function
at nextPreprocessor (/Users/kentcdodds/Developer/alianza/admin-portal/node_modules/karma/lib/preprocessor.js:73:28)
at /Users/kentcdodds/Developer/alianza/admin-portal/node_modules/karma/lib/preprocessor.js:96:7
at /Users/kentcdodds/Developer/alianza/admin-portal/node_modules/karma/node_modules/graceful-fs/graceful-fs.js:76:16
at FSReqWrap.readFileAfterClose as oncomplete

Anything off the top of your head? Everything's working fine with version 0.13.1 but breaks with version 0.13.2. Do you know what might be the problem? Or do you need me to dig more?

@dignifiedquire
Copy link
Member

Thanks for reporting, you are probably right with the commit, but I have no idea how this could happen, as even [].shift() should not throw this error. So if you could find some details, on how this occurs I would be very grateful.

@kentcdodds
Copy link
Contributor Author

This is the code that I'm looking at that's blowing up:

preprocessors.shift()(content, file, nextPreprocessor)

I believe that what's being shifted isn't a function. That's what the error means... Digging...

@kentcdodds
Copy link
Contributor Author

It looks like the line:

instances[name] = injector.get('preprocessor:' + name)

is actually assigning instances[name] to undefined which ultimately gets pushed into the preprocessors (as undefined) and then this error gets thrown.

The preprocessor I'm working with is webpack (I'm using version 1.6.0).

@dignifiedquire
Copy link
Member

Right, I see, thanks a lot for digging. So the best thing is probably to a) not do the assignment when it fails and b) ensure when pushing into preprocessors that the element is not undefined.

@kentcdodds
Copy link
Contributor Author

I agree. In addition, I don't think that this fix will resolve my ultimate issue. Do you know why the webpack preprocessor isn't getting added? Will things work when webpack hasn't yet been added?

@dignifiedquire
Copy link
Member

karma-webpack won't work unless you use my fork codymikol/karma-webpack#63 that is probably what you are running into

@kentcdodds
Copy link
Contributor Author

Ah, I see. Sounds good. I'll subscribe to that PR so I know when it's merged. Thanks for your work on karma! It's beyond invaluable. And thanks for the quick response.

@LPGhatguy
Copy link

I just hit this issue today with Karma 0.13.10 on OS X, upgrading from an older version and tyring to get karma-sourcemap-loader to work. Has there been any progress on fixing this?

@yaring
Copy link

yaring commented Oct 19, 2015

Same error here with 0.13.11 :/

@gejgalis
Copy link

The same error with 0.13.11 on Linux. It works for me on Windows :(
I'm using preprocessor webpack
Node: 0.12.7
NPM: 2.11.3

@vasyl-zubach
Copy link

npm install karma@canary fixed the problem for me

@gep13
Copy link

gep13 commented Nov 17, 2015

Also seeing this issue. Any suggestions on how to fix/work around?

@albohlabs
Copy link

@gep13 I've also run in this error when i was using karma-sourcemap-loader cause i forgot to add it to the plugins property.

plugins: [
  
  'karma-sourcemap-loader'
],

So recheck your karma.conf.js.

@cades
Copy link

cades commented Dec 1, 2015

+1 for karma-live-preprocessor

Edit: I found it's because I forget to put "karma-live-preprocessor" in plugin array. After I add it everything is OK.

@kostia
Copy link
Contributor

kostia commented Jan 4, 2016

Same issue with 0.13.16. 😿

@dignifiedquire
Copy link
Member

Please everyone can you test if #1777 works for you? I'm not able to reproduce the issue myself, so I can only guess atm.

dignifiedquire added a commit to dignifiedquire/karma that referenced this issue Jan 4, 2016
dignifiedquire added a commit to dignifiedquire/karma that referenced this issue Jan 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment