Index.test.js fails connection attempts to localhost:8080 and outputs a PASS test result

Report a Ratel Bug

The test src/index.test.js is clearly having errors, and is attempting to connect (6 times) an invalid address http://localhost:8080 that doesn’t exist, and also had an unhandled exception. Despite what looks like clear failures, the test reported PASS.

What Version of Ratel are you using?

docker pull dgraph/ratel:v21.03.0

What version of Dgraph are you using?

docker pull dgraph/dgraph:v21.03.0

Which Version of the UI are you using

  • Stable
  • Bleeding Edge
  • Local Offline

Have you tried reproducing the issue with the latest release?

git clone git@github.com:dgraph-io/ratel.git

Steps to reproduce the issue (command/config used to run Dgraph).

cd client/src/e2etests
docker-compose -f docker-compose.prod.yml up -d
ratelport="$(docker container port e2etests_ratel_1 8000 | cut -d: -f2)"
alphaport="$(docker container port e2etests_alpha_1 8080 | cut -d: -f2)"
TEST_DGRAPH_SERVER="http://localhost:$alphaport" \
TEST_RATEL_URL="http://localhost:$ratelport?local" \
   npm test -- --runInBand --testTimeout 40000 --watchAll=false

Expected behaviour and actual result.

I didn’t expect tests with such errors, such as ones with ECONNREFUSED, would yield a final PASS.

Actual Results

 PASS  src/index.test.js (13.175 s)
  ● Console

    console.error
      Warning: An update to Editor inside a test was not wrapped in act(...).

      When testing, code that causes React state updates should be wrapped into act(...):

      act(() => {
        /* fire events that update state */
      });
      /* assert on the output */

      This ensures that you're testing the behavior the user would see in the browser. Learn more at https://reactjs.org/link/wrap-tests-with-act
          at Editor (/Users/joaquin/area51/work/ratel/client/src/containers/Editor.js:29:5)
          at div
          at EditorPanel (/Users/joaquin/area51/work/ratel/client/src/components/EditorPanel.js:36:22)
          at div
          at div
          at div
          at VerticalPanelLayout (/Users/joaquin/area51/work/ratel/client/src/components/PanelLayout/VerticalPanelLayout.js:52:5)
          at div
          at QueryView (/Users/joaquin/area51/work/ratel/client/src/components/QueryView/index.js:32:9)
          at div
          at App (/Users/joaquin/area51/work/ratel/client/src/containers/App.js:84:5)
          at Connect(App) (/Users/joaquin/area51/work/ratel/client/node_modules/react-redux/lib/components/connectAdvanced.js:233:41)
          at Provider (/Users/joaquin/area51/work/ratel/client/node_modules/react-redux/lib/components/Provider.js:19:20)
          at AppProvider (/Users/joaquin/area51/work/ratel/client/src/containers/AppProvider.js:108:5)

      52 |         if (offsetHeight !== height) {
      53 |             setTimeout(() => {
    > 54 |                 setHeight(offsetHeight);
         |                 ^
      55 |             });
      56 |         }
      57 |     };

      at printWarning (node_modules/react-dom/cjs/react-dom.development.js:67:30)
      at error (node_modules/react-dom/cjs/react-dom.development.js:43:5)
      at warnIfNotCurrentlyActingUpdatesInDEV (node_modules/react-dom/cjs/react-dom.development.js:24064:9)
      at setHeight (node_modules/react-dom/cjs/react-dom.development.js:16135:9)
      at src/containers/Editor.js:54:17
      at Timeout.task [as _onTimeout] (node_modules/jsdom/lib/jsdom/browser/Window.js:391:19)


  ●  Cannot log after tests are done. Did you forget to wait for something async in your test?
    Attempted to log "serverAclState error FetchError {
      message: 'request to http://localhost:8080/query?timeout=20s failed, reason: connect ECONNREFUSED 127.0.0.1:8080',
      type: 'system',
      errno: 'ECONNREFUSED',
      code: 'ECONNREFUSED'
    }".



      at console.error (node_modules/@jest/console/build/BufferedConsole.js:161:10)
      at _callee4$ (src/actions/connection.js:330:21)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:63:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:293:22)
      at Generator.throw (node_modules/regenerator-runtime/runtime.js:118:21)
      at asyncGeneratorStep (src/actions/connection.js:42:103)
      at _throw (src/actions/connection.js:44:291)
          at runMicrotasks (<anonymous>)


  ●  Cannot log after tests are done. Did you forget to wait for something async in your test?
    Attempted to log "GetHealth error FetchError {
      message: 'request to http://localhost:8080/health failed, reason: connect ECONNREFUSED 127.0.0.1:8080',
      type: 'system',
      errno: 'ECONNREFUSED',
      code: 'ECONNREFUSED'
    }".



      at console.error (node_modules/@jest/console/build/BufferedConsole.js:161:10)
      at _callee5$ (src/actions/connection.js:393:23)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:63:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:293:22)
      at Generator.throw (node_modules/regenerator-runtime/runtime.js:118:21)
      at asyncGeneratorStep (src/actions/connection.js:42:103)
      at _throw (src/actions/connection.js:44:291)
          at runMicrotasks (<anonymous>)


  ●  Cannot log after tests are done. Did you forget to wait for something async in your test?
    Attempted to log "serverAclState error FetchError {
      message: 'request to http://localhost:8080/query?timeout=20s failed, reason: connect ECONNREFUSED 127.0.0.1:8080',
      type: 'system',
      errno: 'ECONNREFUSED',
      code: 'ECONNREFUSED'
    }".



      at console.error (node_modules/@jest/console/build/BufferedConsole.js:161:10)
      at _callee4$ (src/actions/connection.js:330:21)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:63:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:293:22)
      at Generator.throw (node_modules/regenerator-runtime/runtime.js:118:21)
      at asyncGeneratorStep (src/actions/connection.js:42:103)
      at _throw (src/actions/connection.js:44:291)
          at runMicrotasks (<anonymous>)


  ●  Cannot log after tests are done. Did you forget to wait for something async in your test?
    Attempted to log "GetHealth error FetchError {
      message: 'request to http://localhost:8080/health failed, reason: connect ECONNREFUSED 127.0.0.1:8080',
      type: 'system',
      errno: 'ECONNREFUSED',
      code: 'ECONNREFUSED'
    }".



      at console.error (node_modules/@jest/console/build/BufferedConsole.js:161:10)
      at _callee5$ (src/actions/connection.js:393:23)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:63:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:293:22)
      at Generator.throw (node_modules/regenerator-runtime/runtime.js:118:21)
      at asyncGeneratorStep (src/actions/connection.js:42:103)
      at _throw (src/actions/connection.js:44:291)
          at runMicrotasks (<anonymous>)


  ●  Cannot log after tests are done. Did you forget to wait for something async in your test?
    Attempted to log "Editor: Error while fetching ui/keywords FetchError {
      message: 'request to http://localhost:8080/ui/keywords failed, reason: connect ECONNREFUSED 127.0.0.1:8080',
      type: 'system',
      errno: 'ECONNREFUSED',
      code: 'ECONNREFUSED'
    }".

      86 |             setKeywords(kws => kws.concat(result.keywords.map(kw => kw.name)));
      87 |         } catch (error) {
    > 88 |             console.warn("Editor: Error while fetching ui/keywords", error);
         |                     ^
      89 |         }
      90 |     }, [setKeywords]);
      91 |

      at console.warn (node_modules/@jest/console/build/BufferedConsole.js:242:10)
      at _callee2$ (src/containers/Editor.js:88:21)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:63:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:293:22)
      at Generator.throw (node_modules/regenerator-runtime/runtime.js:118:21)
      at asyncGeneratorStep (src/containers/Editor.js:46:103)
      at _throw (src/containers/Editor.js:48:291)
          at runMicrotasks (<anonymous>)


  ●  Cannot log after tests are done. Did you forget to wait for something async in your test?
    Attempted to log "Editor: Error while fetching schema FetchError {
      message: 'request to http://localhost:8080/query?timeout=20s failed, reason: connect ECONNREFUSED 127.0.0.1:8080',
      type: 'system',
      errno: 'ECONNREFUSED',
      code: 'ECONNREFUSED'
    }".

      76 |             }
      77 |         } catch (error) {
    > 78 |             console.warn("Editor: Error while fetching schema", error);
         |                     ^
      79 |         }
      80 |     }, [setKeywords]);
      81 |

      at console.warn (node_modules/@jest/console/build/BufferedConsole.js:242:10)
      at _callee$ (src/containers/Editor.js:78:21)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:63:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:293:22)
      at Generator.throw (node_modules/regenerator-runtime/runtime.js:118:21)
      at asyncGeneratorStep (src/containers/Editor.js:46:103)
      at _throw (src/containers/Editor.js:48:291)
          at runMicrotasks (<anonymous>)