TypeError: jsonPath is not a function
See original GitHub issueHere 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:
- Created 5 years ago
- Comments:8 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jml6m Use jsonpath-plus
+var jsonPath = require(‘jsonpath-plus’);
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