karma-coffee-preprocessor icon indicating copy to clipboard operation
karma-coffee-preprocessor copied to clipboard

Line number for coffee script tests are incorrect

Open evgenyneu opened this issue 12 years ago • 7 comments

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

evgenyneu avatar Oct 30 '13 22:10 evgenyneu

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.

waynegerard avatar Nov 11 '13 00:11 waynegerard

@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.

evgenyneu avatar Nov 12 '13 21:11 evgenyneu

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

baio avatar Feb 04 '14 20:02 baio

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?

amitayd avatar Feb 28 '14 19:02 amitayd

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

jtomaszewski avatar May 27 '14 14:05 jtomaszewski

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

NickClark avatar Jun 05 '14 16:06 NickClark

:( 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

eddiemonge avatar Jul 31 '15 00:07 eddiemonge