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

Babel sourcemaps support #567

Closed
ghost opened this issue Apr 26, 2016 · 13 comments
Closed

Babel sourcemaps support #567

ghost opened this issue Apr 26, 2016 · 13 comments

Comments

@ghost
Copy link

ghost commented Apr 26, 2016

Hi,

Thanks for this. Cucumber + javascript = awesome.

I'm using babel as a compiler. Is there a way that I can tell cucumberjs to use the sourcemaps?

@charlierudolph
Copy link
Member

Use them in what way? In my experience with other compilers, they hook automatically to error stacks. If cucumber-js is loading the babel files, I expect the sourcemaps to be used.

@ghost
Copy link
Author

ghost commented Apr 30, 2016

I must confess, I really don't know much about how source maps work. All I know is when I include them in the directory I'm serving the browser automagically figures it out by looking at the source maps comment at the bottom of the generated file. It seems however that node doesn't figure it out just by it self. I had to use node-source-map-support to get node to understand the source-maps of a little test program I wrote.

Looking at it more carefully though it seems that cucumber js is figuring out where to find the source maps for the error but it's reporting the incorrect line for the step definition. See below:

Scenario:  - test/functional/generateNodeModule/byAnsweringQuestions.feature:5
   Step: When the generator is run without options - test/functional/generateNodeModule/byAnsweringQuestions.feature:6
   Step Definition: test/functional/generateNodeModule/steps.js:217
  Error: This is a fail
         at _callee6$ (run.js:135:11)
         at tryCatch (/Users/Marthinus/Code/platform/sbg-component-generator/node_modules/babel-regenerator-runtime/runtime.js:61:40)

The correct line for the step definition is 77.
Line 135 in run.js is correct however for the error.

@charlierudolph
Copy link
Member

Hmm, can you please provide a sample project setup so I can reproduce?

@ghost
Copy link
Author

ghost commented Apr 30, 2016

Will put something together.

@ghost
Copy link
Author

ghost commented Apr 30, 2016

Ok, clone this. You can read the instructions on the README. I actually don't expect it to do anything else because I'm not telling it where to find or how to produce source maps.

@charlierudolph
Copy link
Member

I get the following output when running on node 6

> cucumber_no_source_map@1.0.0 test /Users/charlesrudolph/github/cucumber_no_source_map
> cucumber-js --format summary --compiler js:babel-register tests/

when block
and block
Failures:

1) Scenario:  - tests/test.feature:4
   Step: Then It should give the correct step definition line number - tests/test.feature:7
   Step Definition: tests/steps.js:15
   Message:
     Error: Error on the it block
         at World._callee$ (steps.js:12:15)
         at tryCatch (/Users/charlesrudolph/github/cucumber_no_source_map/node_modules/babel-regenerator-runtime/runtime.js:61:40)
         at GeneratorFunctionPrototype.invoke [as _invoke] (/Users/charlesrudolph/github/cucumber_no_source_map/node_modules/babel-regenerator-runtime/runtime.js:329:22)
         at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Users/charlesrudolph/github/cucumber_no_source_map/node_modules/babel-regenerator-runtime/runtime.js:94:21)
         at step (/Users/charlesrudolph/github/cucumber_no_source_map/tests/steps.js:3:191)
         at /Users/charlesrudolph/github/cucumber_no_source_map/tests/steps.js:3:451

The line appears correct to me.

@ghost
Copy link
Author

ghost commented Apr 30, 2016

There is no line 15 in steps.js. Step Definition: tests/steps.js:15

@bdo
Copy link

bdo commented Jun 6, 2016

@marthinus-engelbrecht steps.js:12:15 indicates line 12 column 15, so it seems to be working properly (at least on node 6)

@charlierudolph
Copy link
Member

charlierudolph commented Jun 6, 2016

The error stack (Message: line) works properly but when we try to determine the location of the step (Step Definition: line) the source map doesn't appear to be taken into account

@bdo
Copy link

bdo commented Jun 6, 2016

Oh I see. My bad.

@charlierudolph
Copy link
Member

Fixed in 1d02c6a

@ghost
Copy link
Author

ghost commented Jul 5, 2016

Awesome 👍

@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants