eykrehbein / strest

⚡️ CI-ready tests for REST APIs configured in YAML
MIT License
1.74k stars 59 forks source link

Only resolve current call in nunjucks #113

Closed jgroom33 closed 5 years ago

jgroom33 commented 5 years ago
requests:
  value1:
    request:
      url: https://postman-echo.com/get
      method: GET
      queryString:
      - name: foo
        value: bar
  value2:
    request:
      url: https://postman-echo.com/get
      method: GET
      queryString:
      - name: baz
        value: <$ value1.content.args.foo | string $>
    validate:
    - jsonpath: content.args.baz
      expect: bar 

The above fails with:

Testing value1(node:62120) UnhandledPromiseRejectionWarning: Template render error: (unknown path)
  TypeError: Cannot read property 'toString' of undefined
    at Object._prettifyError (/usr/local/lib/node_modules/@strest/cli/node_modules/nunjucks/src/lib.js:36:11)
    at /usr/local/lib/node_modules/@strest/cli/node_modules/nunjucks/src/environment.js:547:19
    at Template.root [as rootRenderFunc] (eval at _compile (/usr/local/lib/node_modules/@strest/cli/node_modules/nunjucks/src/environment.js:617:18), <anonymous>:18:3)
    at Template.render (/usr/local/lib/node_modules/@strest/cli/node_modules/nunjucks/src/environment.js:540:10)
    at Environment.renderString (/usr/local/lib/node_modules/@strest/cli/node_modules/nunjucks/src/environment.js:364:17)
    at Object.exports.computeRequestObject (/usr/local/lib/node_modules/@strest/cli/dist/test.js:323:37)
    at /usr/local/lib/node_modules/@strest/cli/dist/test.js:180:52
    at step (/usr/local/lib/node_modules/@strest/cli/dist/test.js:43:23)
    at Object.next (/usr/local/lib/node_modules/@strest/cli/dist/test.js:24:53)
    at step (/usr/local/lib/node_modules/@strest/cli/dist/test.js:28:139)
(node:62120) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which wasnot handled with .catch(). (rejection id: 3)
(node:62120) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.