question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: jsonPath is not a function

See original GitHub issue

Here is a sample test from my feature file:

Scenario: List Data - All
        Given I set Content-Type header to application/json
        When I GET /myendpoint/all
        Then response body should be valid json
            And response body path $.code should be 200

When I run ./node_modules/.bin/cucumber-js --name "List Data - All" I get this error:

1) Scenario: List Data - All # test\acceptance\features\data.feature:4
   √ Before # test\acceptance\step_definitions\support\apickli-gherkin.js:30
   √ Before # test\acceptance\step_definitions\support\init.js:9
   √ Given I set Content-Type header to application/json # test\acceptance\step_definitions\support\apickli-gherkin.js:40
   √ When I GET /myendpoint/all # test\acceptance\step_definitions\support\apickli-gherkin.js:85
   √ Then response body should be valid json # test\acceptance\step_definitions\support\apickli-gherkin.js:156
   × And response body path $.code should be 200 # test\acceptance\step_definitions\support\apickli-gherkin.js:194
       TypeError: jsonPath is not a function

Previously, I fixed this by running npm install jsonpath --save-dev and I can confirm my package.json lists "jsonpath": "^1.0.0". I’ve tried using ‘–save’ as well, still not working.

This has worked before and I don’t know where the inconsistency is occuring. NOTE: This error doesn’t occur on our linux servers, just my local machine (git bash running on Windows 10)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mrj04commented, May 30, 2018

@jml6m Use jsonpath-plus

+var jsonPath = require(‘jsonpath-plus’);

0reactions
seymencommented, Sep 28, 2018

Your cucumber version is too old (v0.3.5) which was released 3 years ago. Upgrade to v4 or v5. https://github.com/apickli/apickli/blob/master/source/package.json#L29

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix path.json is not a function - javascript
Note i have not developed this code. TypeError: path.json is not a function at app.get ../server.js:22:23) at Layer.handle [as ...
Read more >
TypeError: response.json is not a function in JavaScript
We call the json() method on an object that is not the Response object that resolves from the promise the fetch() method returns....
Read more >
jsonpath
When I try to retrieve 2 elements from an array of objects using the jsonpath notation, it is throwing an exception stating TypeError...
Read more >
JSONPath
Query JavaScript objects with JSONPath expressions. Robust / safe JSONPath engine for Node.js.. Latest version: 1.1.1, last published: 2 ...
Read more >
TypeError: "x" is not a function - JavaScript - MDN Web Docs
Maybe there is a typo in the function name? Maybe the object you are calling the method on does not have this function?...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found