assaf / node-replay

When API testing slows you down: record and replay HTTP responses like a boss
http://documentup.com/assaf/node-replay
MIT License
522 stars 107 forks source link

Tests fail on Windows; Node 8.9.4 #146

Closed adamschneider closed 5 years ago

adamschneider commented 6 years ago

First off, I love this tool. However, it seems to be broken in newer versions of Node (at least on Windows). I was going to take a stab at fixing some of the breakage but I'm noticing that the tests fail with no modification. I can observe that TravisCI passes when using Node8. Has anyone attempted developing this on Windows? Am I running this correctly? Below is the output of my attempt to test the library. Thanks!

PS E:\programming\node-replay> node -v
v8.9.4
PS E:\programming\node-replay> npm -v
5.6.0
PS E:\programming\node-replay> npm install
npm WARN prepublish-on-install As of npm@5, `prepublish` scripts are deprecated.
npm WARN prepublish-on-install Use `prepare` for build steps and `prepublishOnly` for upload-only.
npm WARN prepublish-on-install See the deprecation note in `npm help scripts` for more information.

> replay@2.1.4 prepublish E:\programming\node-replay
> gulp build

[21:23:11] Using gulpfile E:\programming\node-replay\gulpfile.js
[21:23:11] Starting 'clean'...
[21:23:11] Starting 'lint'...
[21:23:12] Finished 'clean' after 975 ms
[21:23:12] Finished 'lint' after 1.2 s
[21:23:12] Starting 'build'...
[21:23:13] gulp-notify: [Gulp notification] node-replay: built!
[21:23:13] Finished 'build' after 570 ms
npm WARN ajv-keywords@3.1.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN replay@2.1.4 No license field.

up to date in 14.087s
PS E:\programming\node-replay> npm run test

> replay@2.1.4 test E:\programming\node-replay
> mocha

(node:11640) DeprecationWarning: "--compilers" will be removed in a future version of Mocha; see https://git.io/vdcSr for more info
  Pass through
    bloody
      listeners
        √ should return HTTP version
        √ should return status code
        √ should return response trailers
        √ should return response headers
        √ should return response body
      callback
        √ should return HTTP version
        √ should return status code
        √ should return response headers
        √ should return response trailers
        √ should return response body
    ssl
      get
        √ should return HTTP version
        √ should return status code
        √ should return response headers
        √ should return response trailers
        √ should return response body
      post
        √ should return status code
        √ should post the body
    replay
      listeners
        √ should callback with error
      localhost
        √ should pass through by default

  Replay
    matching URL
      listeners
        1) "before all" hook
      Old http status line format
        2) "before all" hook
      callback
        3) "before all" hook
    matching on query strings
      4) "before all" hook
    matching an https url
      √ should return HTTP version
      √ should return status code
    matching a regexp
      5) "before all" hook
    matching a regexp url with flags
      6) "before all" hook
    matching when changing fixtures dir
      original catalog
        7) "before all" hook
      alternative catalog
        8) "before all" hook
    recording query parameters
      √ should create a fixture per unique URL path (40ms)
    recording gzipped replay
      √ should create unzipped fixture for gzipped reply
    recording multiple of the same header
      √ should create a fixture with multiple set-cookie headers
      replaying multiple headers
        √ should have both set-cookie headers
    recording POST data
      without record response control
        √ should save POST request data
      with record response control
        that indicates response should be recorded
          √ should save POST request data
        that indicates response should not be recorded
          √ should not save POST request data
    recording multi-line POST data
      √ should save POST request data
    replaying with POST body
      matching
        9) "before all" hook
    replaying with multi-line POST body
      matching
        10) "before all" hook
    only specified headers
      √ should not store the accept header
    undefined path
      √ should callback with error
    undefined host
      √ should callback with error
    header
      matching
        11) "before all" hook
      no match
        √ should fail to connnect
    method
      matching
        12) "before all" hook
      no match
        √ should fail to connnect
    corrupt replay file
      √ should callback with error
    minimal response
      listeners
        13) "before all" hook

  35 passing (561ms)
  13 failing

  1) Replay
       matching URL
         listeners
           "before all" hook:
     TypeError: Cannot read property 'slice' of null
      at parseHeaders (E:/programming/node-replay/src/catalog.js:32:25)
      at parseRequest (E:/programming/node-replay/src/catalog.js:64:19)
      at Catalog._read (E:/programming/node-replay/src/catalog.js:245:17)
      at Catalog.find (E:/programming/node-replay/src/catalog.js:184:28)
      at E:/programming/node-replay/src/recorder.js:15:32
      at Function.layer [as next] (E:/programming/node-replay/src/chain.js:50:7)
      at E:/programming/node-replay/src/chain.js:54:17
      at E:/programming/node-replay/src/logger.js:16:5
      at Function.layer [as next] (E:/programming/node-replay/src/chain.js:50:7)
      at E:/programming/node-replay/src/chain.js:54:17
      at E:/programming/node-replay/src/pass_through.js:68:7
      at ProxyRequest.layer (E:/programming/node-replay/src/chain.js:50:7)
      at ProxyRequest.end (E:/programming/node-replay/src/proxy.js:117:10)
      at Object.HTTP.get (E:/programming/node-replay/src/patch_http_request.js:34:7)
      at Context.<anonymous> (E:/programming/node-replay/test/replay_test.js:27:12)

  2) Replay
       matching URL
         Old http status line format
           "before all" hook:
     Error: GET http://example.com:3002/weather?c=94606&statusLineFormat=old refused: not recording and no network access
      at Immediate.setImmediate (E:/programming/node-replay/src/proxy.js:127:25)

  3) Replay
       matching URL
         callback
           "before all" hook:
     Error: GET http://example.com:3002/weather?c=94606 refused: not recording and no network access
      at Immediate.setImmediate (E:/programming/node-replay/src/proxy.js:127:25)

  4) Replay
       matching on query strings
         "before all" hook:
     Error: GET http://example.com:3002/query?param=1 refused: not recording and no network access
      at Immediate.setImmediate (E:/programming/node-replay/src/proxy.js:127:25)

  5) Replay
       matching a regexp
         "before all" hook:
     Error: GET http://example.com:3002/regexp refused: not recording and no network access
      at Immediate.setImmediate (E:/programming/node-replay/src/proxy.js:127:25)

  6) Replay
       matching a regexp url with flags
         "before all" hook:
     Error: GET http://example.com:3002/aregexp2 refused: not recording and no network access
      at Immediate.setImmediate (E:/programming/node-replay/src/proxy.js:127:25)

  7) Replay
       matching when changing fixtures dir
         original catalog
           "before all" hook:
     Error: GET http://example.com:3002/weather?c=94606 refused: not recording and no network access
      at Immediate.setImmediate (E:/programming/node-replay/src/proxy.js:127:25)

  8) Replay
       matching when changing fixtures dir
         alternative catalog
           "before all" hook:
     TypeError: Cannot read property 'slice' of null
      at parseHeaders (E:/programming/node-replay/src/catalog.js:32:25)
      at parseRequest (E:/programming/node-replay/src/catalog.js:64:19)
      at Catalog._read (E:/programming/node-replay/src/catalog.js:245:17)
      at Catalog.find (E:/programming/node-replay/src/catalog.js:184:28)
      at E:/programming/node-replay/src/recorder.js:15:32
      at Function.layer [as next] (E:/programming/node-replay/src/chain.js:50:7)
      at E:/programming/node-replay/src/chain.js:54:17
      at E:/programming/node-replay/src/logger.js:16:5
      at Function.layer [as next] (E:/programming/node-replay/src/chain.js:50:7)
      at E:/programming/node-replay/src/chain.js:54:17
      at E:/programming/node-replay/src/pass_through.js:68:7
      at ProxyRequest.layer (E:/programming/node-replay/src/chain.js:50:7)
      at ProxyRequest.end (E:/programming/node-replay/src/proxy.js:117:10)
      at Object.HTTP.get (E:/programming/node-replay/src/patch_http_request.js:34:7)
      at Context.<anonymous> (E:/programming/node-replay/test/replay_test.js:273:14)

  9) Replay
       replaying with POST body
         matching
           "before all" hook:
     TypeError: Cannot read property 'slice' of null
      at parseHeaders (E:/programming/node-replay/src/catalog.js:32:25)
      at parseRequest (E:/programming/node-replay/src/catalog.js:64:19)
      at Catalog._read (E:/programming/node-replay/src/catalog.js:245:17)
      at Catalog.find (E:/programming/node-replay/src/catalog.js:184:28)
      at E:/programming/node-replay/src/recorder.js:15:32
      at Function.layer [as next] (E:/programming/node-replay/src/chain.js:50:7)
      at E:/programming/node-replay/src/chain.js:54:17
      at E:/programming/node-replay/src/logger.js:16:5
      at Function.layer [as next] (E:/programming/node-replay/src/chain.js:50:7)
      at E:/programming/node-replay/src/chain.js:54:17
      at E:/programming/node-replay/src/pass_through.js:68:7
      at ProxyRequest.layer (E:/programming/node-replay/src/chain.js:50:7)
      at ProxyRequest.end (E:/programming/node-replay/src/proxy.js:117:10)
      at Context.<anonymous> (E:/programming/node-replay/test/replay_test.js:612:17)

  10) Replay
       replaying with multi-line POST body
         matching
           "before all" hook:
     Error: POST http://example.com:3002/post-body-multi refused: not recording and no network access
      at Immediate.setImmediate (E:/programming/node-replay/src/proxy.js:127:25)

  11) Replay
       header
         matching
           "before all" hook:
     Error: GET http://example.com:3002/weather.json refused: not recording and no network access
      at Immediate.setImmediate (E:/programming/node-replay/src/proxy.js:127:25)

  12) Replay
       method
         matching
           "before all" hook:
     Error: POST http://example.com:3002/posts refused: not recording and no network access
      at Immediate.setImmediate (E:/programming/node-replay/src/proxy.js:127:25)

  13) Replay
       minimal response
         listeners
           "before all" hook:
     Error: GET http://example.com:3002/minimal refused: not recording and no network access
      at Immediate.setImmediate (E:/programming/node-replay/src/proxy.js:127:25)

An error occured. { Error: spawn growlnotify ENOENT
    at _errnoException (util.js:1022:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
    at onErrorNT (internal/child_process.js:372:16)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
  code: 'ENOENT',
  errno: 'ENOENT',
  syscall: 'spawn growlnotify',
  path: 'growlnotify',
  spawnargs:
   [ '/i:E:\\programming\\node-replay\\node_modules\\mocha\\images\\error.png',
     '13 of 62 tests failed',
     '/t:Failed' ] }
npm ERR! code ELIFECYCLE
npm ERR! errno 13
npm ERR! replay@2.1.4 test: `mocha`
npm ERR! Exit status 13
npm ERR!
npm ERR! Failed at the replay@2.1.4 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Me\AppData\Roaming\npm-cache\_logs\2018-02-26T05_20_06_716Z-debug.log
ggb667 commented 6 years ago

Does this work on earlier versions of node 8? I'm trying to recommend something and node-replay looks great, but we will need to move to node 8 quite soon.

adamschneider commented 6 years ago

This project appears to have lost the attention of it's maintainer. There are a couple other alternatives, like: sepia, vcr, or yakbak. I haven't investigated to see if those are maintained. Sorry.

ggb667 commented 6 years ago

Thats a real shame, because this is a great tool.

Do you know what's wrong with the tests?

On Tue, Mar 6, 2018 at 9:48 AM, adamschneider notifications@github.com wrote:

This project appears to have lost the attention of it's maintainer. There are a couple other alternatives, like: sepia, vcr, or yakbak. I haven't investigated to see if those are maintained. Sorry.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/assaf/node-replay/issues/146#issuecomment-370805232, or mute the thread https://github.com/notifications/unsubscribe-auth/ACSGbi21CZiksazRpH8_z1rNqJxY6CGrks5tbqHOgaJpZM4SSsuT .

--

Gregory G. Bishop Sr. Software Engineer

3088 Downs Cove Rd. Windermere FL 34786 321-276-8588 ggb667@gmail.com

adamschneider commented 6 years ago

I haven't looked into this library since my initial comment.

I've recently had success using this library: https://github.com/node-nock/nock

assaf commented 6 years ago

I'm using it with Node 9.8.0, but Linux + MacOS, not tested to work in Windows.

ggb667 commented 6 years ago

Can someone please test this on windows?

s25g5d4 commented 6 years ago

Works for me, at commit b01018e89faa260d3663c9d07f940ad47692d316. Windows 10 Pro Version 1803 Build 17134.48.

s25g5d4@DESKTOP-1QN2Q14 MINGW32 ~/Code/node-replay (master)
$ node -v
v8.9.4

s25g5d4@DESKTOP-1QN2Q14 MINGW32 ~/Code/node-replay (master)
$ npm -v
5.8.0

s25g5d4@DESKTOP-1QN2Q14 MINGW32 ~/Code/node-replay (master)
$ npm i

> replay@2.3.0 prepare C:\Users\s25g5d4\Code\node-replay
> gulp build

[11:03:10] Using gulpfile ~\Code\node-replay\gulpfile.js
[11:03:10] Starting 'clean'...
[11:03:10] Starting 'lint'...
[11:03:11] Finished 'clean' after 1.58 s
[11:03:12] Finished 'lint' after 2.35 s
[11:03:12] Starting 'build'...
[11:03:13] gulp-notify: [Gulp notification] node-replay: built!
[11:03:13] Finished 'build' after 1.39 s
npm WARN replay@2.3.0 No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.3 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

added 712 packages from 815 contributors in 39.587s

s25g5d4@DESKTOP-1QN2Q14 MINGW32 ~/Code/node-replay (master)
$ npm test

> replay@2.3.0 test C:\Users\s25g5d4\Code\node-replay
> mocha

  Pass through
    bloody
      listeners
        √ should return HTTP version
        √ should return status code
        √ should return response trailers
        √ should return response headers
        √ should return response body
      callback
        √ should return HTTP version
        √ should return status code
        √ should return response headers
        √ should return response trailers
        √ should return response body
    ssl
      get
        √ should return HTTP version
        √ should return status code
        √ should return response headers
        √ should return response trailers
        √ should return response body
      post
        √ should return status code
        √ should post the body
    replay
      listeners
        √ should callback with error
      localhost
        √ should pass through by default

  Replay
    matching URL
      listeners
        √ should return HTTP version
        √ should return status code
        √ should return response headers
        √ should return response trailers
      Old http status line format
        √ should return HTTP version
        √ should return status code
        √ should return response headers
        √ should return response trailers
      callback
        √ should return HTTP version
        √ should return status code
        √ should return response headers
        √ should return response trailers
    matching on query strings
      √ should select the correct fixture
    matching an https url
      √ should return HTTP version
      √ should return status code
    matching a regexp
      √ should match the right fixture
    matching a regexp url with flags
      √ should match a fixture
    matching when changing fixtures dir
      original catalog
        √ should match to response in original catalog
      alternative catalog
        √ should match to response in original catalog
    recording query parameters
      √ should create a fixture per unique URL path (53ms)
    recording gzipped replay
      √ should create unzipped fixture for gzipped reply
    recording multiple of the same header
      √ should create a fixture with multiple set-cookie headers
      replaying multiple headers
        √ should have both set-cookie headers
    recording POST data
      without record response control
        √ should save POST request data
      with record response control
        that indicates response should be recorded
          √ should save POST request data
        that indicates response should not be recorded
          √ should not save POST request data
    recording multi-line POST data
      √ should save POST request data
    replaying with POST body
      matching
        √ should return status code
    replaying with multi-line POST body
      matching
        √ should return status code
    replaying with POST body regular expression
      matching
        √ should return status code
      not matching
        √ should callback with error
    only specified headers
      √ should not store the accept header
    undefined path
      √ should callback with error
    undefined host
      √ should callback with error
    header
      matching
        √ should return status code
      no match
        √ should fail to connnect
    method
      matching
        √ should return status code
        √ should return headers
      no match
        √ should fail to connnect
    corrupt replay file
      √ should callback with error
    minimal response
      listeners
        √ should return HTTP version
        √ should return status code
        √ should return no response headers
        √ should return no response trailers
        √ should return no response body

  64 passing (697ms)

An error occured. { Error: spawn growlnotify ENOENT
    at _errnoException (util.js:1022:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
    at onErrorNT (internal/child_process.js:372:16)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
  code: 'ENOENT',
  errno: 'ENOENT',
  syscall: 'spawn growlnotify',
  path: 'growlnotify',
  spawnargs:
   [ '/i:C:\\Users\\s25g5d4\\Code\\node-replay\\node_modules\\mocha\\images\\ok.png',
     '64 tests passed in 697ms',
     '/t:Passed' ] }

Ignore the error at the end. That's notification for test pass, and I don't have the program installed.