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

gdal.config.set is not a function #207

Closed
AlokBansal8 opened this issue Jul 20, 2017 · 4 comments
Closed

gdal.config.set is not a function #207

AlokBansal8 opened this issue Jul 20, 2017 · 4 comments

Comments

@AlokBansal8
Copy link

AlokBansal8 commented Jul 20, 2017

When I try to run multiple test files using jest, I get following error:

 PASS  src/server/gis/common/value-calculator.test.js
 FAIL  src/server/gis/raster/index.test.js
  ● Test suite failed to run

    TypeError: gdal.config.set is not a function
      
      at Object.<anonymous> (node_modules/gdal/lib/gdal.js:58:14)
      at Object.<anonymous> (src/server/gis/raster/index.js:3:39)
      at Object.<anonymous> (src/server/gis/raster/index.test.js:3:14)
          at <anonymous>

But everything works fine if I run only one test file (whichever it may be).

@AlokBansal8
Copy link
Author

For your reference line 3 of index.js is

import gdal from 'gdal'

@AlokBansal8
Copy link
Author

@brandonreavis @brianreavis Please help. I am not able to write a comprehensive test suite for my project.

@brandonreavis
Copy link
Member

I am not very familiar with Jest, but it looks like jest is loading and running the same module twice in the same process, which is not what node is supposed to do. import should load the module once, and add it to the cache.

If loaded twice, these lines cause gdal.config.set to be undefined:

https://github.com/naturalatlas/node-gdal/blob/master/lib/gdal.js#L52-L55

I'd recommend asking someone who understands jest if there is a way to have dependencies only loaded once.

@eduardogspereira
Copy link
Contributor

Hi @AlokBansal8,

I had the same problem here. To solve it I inserted the GDAL_DATA variable on the tests.

"test": "GDAL_DATA=node_modules/gdal/deps/libgdal/gdal/data jest int --coverage --watch"

👍🚴‍♂️🚴‍♂️

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