Kong / insomnia

The open-source, cross-platform API client for GraphQL, REST, WebSockets, SSE and gRPC. With Cloud, Local and Git storage.
https://insomnia.rest
Apache License 2.0
34.84k stars 1.97k forks source link

Inso run test fails, ERROR: Cannot read property 'now' of undefined #3799

Open xeras opened 3 years ago

xeras commented 3 years ago

Describe the bug Running tests with inso cli inso run test results into an error.

> inso run test                    
✔ Select a document or unit test suite · <collection name>
✔ Select an environment · Staging - <env name>
This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills
This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills

 ERROR  Cannot read property 'now' of undefined                                                                                                                                                                                                                                                                       

  at Object.<anonymous> (/usr/lib/node_modules/insomnia-inso/node_modules/insomnia-send-request/dist/index.js:32481:98)
  at Object.<anonymous> (/usr/lib/node_modules/insomnia-inso/node_modules/insomnia-send-request/dist/index.js:32491:30)
  at __webpack_require__ (/usr/lib/node_modules/insomnia-inso/node_modules/insomnia-send-request/dist/index.js:21:30)
  at Object.<anonymous> (/usr/lib/node_modules/insomnia-inso/node_modules/insomnia-send-request/dist/index.js:32460:20)
  at __webpack_require__ (/usr/lib/node_modules/insomnia-inso/node_modules/insomnia-send-request/dist/index.js:21:30)
  at Object.<anonymous> (/usr/lib/node_modules/insomnia-inso/node_modules/insomnia-send-request/dist/index.js:32169:59)
  at Object.<anonymous> (/usr/lib/node_modules/insomnia-inso/node_modules/insomnia-send-request/dist/index.js:32450:30)
  at __webpack_require__ (/usr/lib/node_modules/insomnia-inso/node_modules/insomnia-send-request/dist/index.js:21:30)
  at Object.<anonymous> (/usr/lib/node_modules/insomnia-inso/node_modules/insomnia-send-request/dist/index.js:32148:20)
  at __webpack_require__ (/usr/lib/node_modules/insomnia-inso/node_modules/insomnia-send-request/dist/index.js:21:30)

ℹ To view tracing information, re-run inso with --verbose

To Reproduce Steps to reproduce the behavior:

  1. Go to command line
  2. execute inso cli
  3. select a design document containing tests
  4. select an environment
  5. execute the tests
  6. See the error described above

Expected behavior Inso CLI runs the tests as expected without throwing errors.

Desktop (please complete the following information):

mdhenriksen commented 3 years ago

I'm encountering the same error using macOS big sur. I've made the same steps as @xeras.

develohpanda commented 3 years ago

Hi @mdhenriksen, the request being run by the test, is that by any chance consuming a plugin or template tag? If that's the case, unfortunately plugins are not yet supported with Inso, though we do plan to allow this - I suggest following this thread.

It would be incredibly useful for us if you are able to provide a document export that we can validate with!

mdhenriksen commented 3 years ago

Hey @develohpanda! The request is using an environment variable tag (I guess thats a template tag).

However, I've just created a completely new test, that only sends a GET request without any parameters, tags or what so ever - and I'm still hitting the same error.

My steps are as follows:

  1. Create design document
  2. Under the "debug" tab, create GET request pointed at https://api.chucknorris.io/jokes/random
  3. Under the "test tab, create default test to see if response code is 200
  4. Validate the test works in Insomnia
  5. Go to terminal, run inso run test and find and run the test suite
develohpanda commented 3 years ago

Thank you for those steps! Environment variables should be supported just fine, it's more if there are any custom plugins. I followed your steps above and it seems to be working as intended.

image

Could you please confirm which version of Insomnia and Inso you are using? Are they both the current latest versions?

mdhenriksen commented 3 years ago

Weird it works for you.

I have a few plugins installed, but that's fine as long at they are not used in the actual requests and tests, right?

These are my versions:

Full specifications on my Insomnia installation:

Version: Insomnia 2021.5.2
Release date: 31/08/2021
OS: Darwin x64 20.6.0
Electron: 11.2.3
Node: 12.18.3
V8: 8.7.220.31-electron.0
Architecture: x64
node-libcurl: libcurl/7.73.0 OpenSSL/1.1.1k zlib/1.2.11 brotli/1.0.9 zstd/1.4.9 libidn2/2.1.1 libssh2/1.9.0 nghttp2/1.42.0
develohpanda commented 3 years ago

I have a few plugins installed, but that's fine as long at they are not used in the actual requests and tests, right?

In theory yes, there might be a situation where an environment variable that uses a template tag/plugin could cause an issue. But you're able to reproduce this with a brand new design document (right?), so environment variables won't play a part.

(I also mistakenly thought Inso 2.3.0 was the latest, however I get the same success response using Inso 2.3.2.)

glanchow commented 3 years ago

 I had the same problem with all node v16 versions, but it worked with v14

nvm install v14.18.1
Now using node v14.18.1 (npm v6.14.15)
npm install -g insomnia-inso
inso run test
develohpanda commented 3 years ago

Oh that's a good point^. Inso only works (currently) with Node 12. We've released single-executable binaries which you can access from GitHub Releases if you want to skip installing via NPM.

filfreire commented 2 years ago

Hi @xeras, @mdhenriksen @glanchow, are you folks still getting this error in latest stable (or beta) version of Inso CLI?