Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

supertest should return response instead of @nightwatch_element #2

Open
reallymello opened this issue Dec 30, 2022 · 0 comments
Open

Comments

@reallymello
Copy link
Contributor

In a normal SuperTest test one can save out the response to perform later assertions on or save the data for more complicated tests. When I try that it appears the response comes back as a @nightwatch_element instead so it doesn't appear that it is possible. Could that be added?

module.exports = {
  'can do a test': ({ supertest }) => {
    const response = supertest
      .request('https://petstore.swagger.io/v2')
      .get('/store/inventory/')
      .expect(200)
      .expect('Content-Type', /json/)
      .end(() => {});

    expect(response.status).to.equal(200);
  },
};
┌ ────────────────── ×  default: petStore.js  ───────────────────────────────────────────────────────────────────────────────────┐
│                                                                                                                                │
│                                                                                                                                │
│    [Pet Store] Test Suite                                                                                                      │
│    ────────────────────────────────────────────                                                                                │
│    – can do a test                                                                                                             │
│     ✖ TypeError                                                                                                                │
│       Cannot read properties of undefined (reading '@nightwatch_element')                                                      │
│                                                                                                                                │
│        Error location:                                                                                                         │
│        C:\Projects\nightwatchTutorials\apiTesting\test\petStore.js:                                                            │
│        –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––                                                           │
│         8 |       .end(() => {});                                                                                              │
│         9 |                                                                                                                    │
│         10 |     expect(response.status).to.equal(200);                                                                        │
│         11 |   },                                                                                                              │
│         12 | };                                                                                                                │
│        –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––                                                           │
│                                                                                                                                │
│        Stack Trace :                                                                                                           │
│        at NightwatchAPI.expect (C:\Users\Mr\AppData\Roaming\npm\node_modules\nightwatch\lib\api\_loaders\static.js:233:62)     │
│        at globalExpect (C:\Users\Mr\AppData\Roaming\npm\node_modules\nightwatch\lib\testsuite\index.js:311:29)                 │
│        at Object.can do a test (C:\Projects\nightwatchTutorials\apiTesting\test\petStore.js:10:5)                              │
│        at Context.call (C:\Users\Mr\AppData\Roaming\npm\node_modules\nightwatch\lib\testsuite\context.js:476:35)               │
│        at TestCase.run (C:\Users\Mr\AppData\Roaming\npm\node_modules\nightwatch\lib\testsuite\testcase.js:58:31)               │
│        at Runnable.__runFn (C:\Users\Mr\AppData\Roaming\npm\node_modules\nightwatch\lib\testsuite\index.js:745:80)             │
│        at Runnable.run (C:\Users\Mr\AppData\Roaming\npm\node_modules\nightwatch\lib\testsuite\runnable.js:126:21)              │
│        at TestSuite.executeRunnable (C:\Users\Mr\AppData\Roaming\npm\node_modules\nightwatch\lib\testsuite\index.js:898:49)    │
│        at TestSuite.handleRunnable (C:\Users\Mr\AppData\Roaming\npm\node_modules\nightwatch\lib\testsuite\index.js:913:33)     │
│        at C:\Users\Mr\AppData\Roaming\npm\node_modules\nightwatch\lib\testsuite\index.js:745:21                                │
│                                                                                                                                │
│    × default: petStore.js [Pet Store] can do a test (78ms)                                                                     │
│       Cannot read properties of undefined (reading '@nightwatch_element')                                                      │
│       TypeError: Cannot read properties of undefined (reading '@nightwatch_element')                                           │
│           at Object.can do a test (C:\Projects\nightwatchTutorials\apiTesting\test\petStore.js:10:5)                           │
│    √ Passed [ok]: .get('/store/inventory/').expect(200) ok                                                                     │
│    √ Passed [ok]: .get('/store/inventory/').expect('Content-Type', /json/) ok                                                  │
│                                                                                                                                │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant