karma-runner / karma-coffee-preprocessor

A Karma plugin. Compile coffee script on the fly.
MIT License
53 stars 34 forks source link

Line number for coffee script tests are incorrect #12

Open evgenyneu opened 11 years ago

evgenyneu commented 11 years ago

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: karma@0.10.4 karma-coffee-preprocessor@0.1.0 coffee-script@1.6.3

Thank you

waynegerard commented 11 years ago

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 commented 11 years ago

@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 commented 10 years ago

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

amitayd commented 10 years ago

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 commented 10 years ago

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

NickClark commented 10 years ago

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 commented 9 years ago

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