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

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

Open
asbates opened this issue Sep 18, 2020 · 0 comments
Open

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

asbates opened this issue Sep 18, 2020 · 0 comments

Comments

@asbates
Copy link
Contributor

asbates commented Sep 18, 2020

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.

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