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

webpack preprocessor not running #28

Open
jnewman opened this issue Apr 26, 2016 · 10 comments
Open

webpack preprocessor not running #28

jnewman opened this issue Apr 26, 2016 · 10 comments

Comments

@jnewman
Copy link

jnewman commented Apr 26, 2016

I've got my tests setup w/ webpack and coverage preprocessors. These work as expected via CLI, but when I try to run via karma-intellij I get the following error (which makes me think the preprocessor isn't running):

SyntaxError: Use of reserved word 'import'
at http://localhost:9876/base/unit/attributes.spec.js?bf8f6bdd21402ea57b8260880929c7b7742f7d4b:57

Here's the config file I'm trying to use:

https://github.com/krux/prescribe/blob/jnewman-repro-intellij-integration-issue/test/karma-idea.config.js

Any pointers would be helpful. I've got a similar setup w/ coffee script preprocessors that works exactly as planned, so I'm wondering if it's something specific about multiple preprocessors.

For reference, I've attached images of my setup:

screen shot 2016-04-26 at 5 09 15 pm
screen shot 2016-04-26 at 5 19 02 pm

IntelliJ details:

IntelliJ IDEA 2016.1.1
Build #IU-145.597, built on March 29, 2016
JRE: 1.8.0_40-release-b132 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
@segrey
Copy link
Contributor

segrey commented Apr 27, 2016

Thanks, reproduced. Caused by current working directory specified when running karma process.
When running test/karma-idea.config.js in terminal, cwd=/path/to/prescribe. However, karma-intellij sets cwd=/path/to/prescribe/test. I thought karma is cwd-agnostic, but looks like unfortunately it is not true anymore. Possible fix is to add "Working directory" parameter to Karma run configuration dialog. Any other ideas how to solve this cwd-problem?

@segrey
Copy link
Contributor

segrey commented Apr 27, 2016

Tried to create prescribe/karma.conf.js with this content

module.exports = require('./test/karma-idea.config');

And it fails in Terminal when running as ./node_modules/karma/bin/karma start karma.conf.js. No ideas why.
At the same time ./node_modules/karma/bin/karma start ./test/karma-idea.config.js runs correctly. Just curious what I'm missing?

@jnewman
Copy link
Author

jnewman commented Apr 27, 2016

I changed the js file to:

require('babel-register');
require('process');
process.chdir('..');
module.exports = require('./karma-coverage.config.babel');

@jnewman
Copy link
Author

jnewman commented Apr 27, 2016

Seems to work like that!

Maybe this is just adding that to the docs 😄

@jnewman
Copy link
Author

jnewman commented Apr 27, 2016

Thanks so much for the help on this!

@segrey
Copy link
Contributor

segrey commented Apr 27, 2016

Great! It works for me too. However, I'm still in the dark why this doesn't work, prescribe/karma.conf.js:

require('babel-register');
module.exports = require('./test/karma-coverage.config.babel');

@jnewman
Copy link
Author

jnewman commented Apr 27, 2016

I think b/c webpack gets confused about which directory it's in.

@Macavity
Copy link

Macavity commented Jan 27, 2017

I got the same problem using browserify instead of webpack, thus the workaround doesn't work for me. Any ideas on how to make karma use the configured "base" as work directory for running single specs?

@segrey
Copy link
Contributor

segrey commented Jan 27, 2017

@Macavity Not sure I understand your problem fully. Could you please provide mode details about it in a separate issue?

@Macavity
Copy link

Sure, will do.

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