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

Line number for coffee script tests are incorrect #12

Open
evgenyneu opened this issue Oct 30, 2013 · 7 comments
Open

Line number for coffee script tests are incorrect #12

evgenyneu opened this issue Oct 30, 2013 · 7 comments

Comments

@evgenyneu
Copy link

Hi, can anyone help me to setup karma to show error line numbers correctly for CoffeScript tests?

For the following test the report contains text test_spec.coffee:3:26. I assume that 3 is the line number, which is not quite right. It should be 2, not 3.

describe 'test', ->
  it 'fails', -> expect(false).toBe true

Test output:

Chrome 30.0.1599 (Mac OS X 10.8.4) test fails FAILED
    Expected false to be true.
    Error: Expected false to be true.
        at null.<anonymous> (...test_spec.coffee:3:26)

My config:

preprocessors: {
  '**/*.coffee': ['coffee']
},
coffeePreprocessor: {
  options: {
    bare: true,
    sourceMap: true
  },
  transformPath: function(path) {
    return path.replace(/\.js$/, '.coffee');
  }
}

I am using:
[email protected]
[email protected]
[email protected]

Thank you

@waynegerard
Copy link

What does the compiled coffee script look like? I would bet that the line mentioned in the error is of the transpiled coffeescript (i.e. the javascript), not the original coffeescript file.

@evgenyneu
Copy link
Author

@waynegerard, the JavaScript is

(function() {
  describe('test', function() {
    return it('fails', function() {
      return expect(false).toBe(true);
    });
  });
}).call(this);

It is interesting, because error line numbers do not match JavaScript either. It is even more interesting because today there are no line numbers in the error report at all.

PhantomJS 1.9.2 (Mac OS X) test fails FAILED
Expected false to be true.

@baio
Copy link

baio commented Feb 4, 2014

Hi! I have similar problem, in log window shown js number lines, not coffee how I could change this?

@amitayd
Copy link

amitayd commented Feb 28, 2014

Same here. Can anyone clarify that it is a non-implemented feature (using pre-processors sourcemaps to show line numbers in origin file)?
If it is supposed to be working, is any additional information needed regarding to configuration?

@jtomaszewski
Copy link

If you use default configuration, line numbers should be working - but not in PhantomJS. Switching to Chrome fixed the problem for me.

@NickClark
Copy link

Same here. It seems to be a problem with PhantomJS. Running in Chrome fixes the issue. Too bad too, I much prefer error messages like TypeError: 'undefined' is not a function (evaluating 'calc.add()') to TypeError: undefined is not a function

@eddiemonge
Copy link

:( this should be supported by now.

edit: jk maybe it does. Setting sourceMap to true seems to do it: https://github.com/karma-runner/karma-coffee-preprocessor#configuration

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

7 participants