Skip to content

Testing the Server - need .get before .expect #217

@asbates

Description

@asbates

For the 404 test in the 'Testing the Server' section, I think the .get needs to be called before .expect.

The test is

  it('should 404 for other pages', (done) => {
    request(server)
      .expect(404) // expect first
      .get('/other')
      .end((err, res) => {
        assert(res.text.includes('ERROR'), 'Has expected error message')
        done()
      })
  })

When I runs the tests with this, I get TypeError: request(...).expect is not a function.

I think it should be

  it('should 404 for other pages', (done) => {
    request(server)
      .get('/other') // get first
      .expect(404)
     // ...
      })
  })

where the get request is made before we can check the result is as expected. Doing this results in a passing test for me.

Happy to submit a PR if you all agree with my assessment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions