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

custom expectations #16

Closed
tadeuszwojcik opened this issue Aug 13, 2012 · 5 comments
Closed

custom expectations #16

tadeuszwojcik opened this issue Aug 13, 2012 · 5 comments

Comments

@tadeuszwojcik
Copy link

Hi,
I was wondering, how bad it would be if supertest would export lib/Test to allow add custom (application specific) expectations?
My use case is that I want to test expressjs routes and need to test in many places thinks like 'unauthorized', 'unauthenticated', 'owneronly' conditions for many urls, so currently I do:

  request(app)
      .get('/test/threads/34567/edit')
      .expect(500)
      .expect(/Unauthenticated/)
      .end(done);

but would prefer something like:

  request(app)
      .get('/test/threads/34567/edit')
      .expectUnauthenticatedError()
      .end(done);

Pros of that approach is that I have to test such things for many urls, so test code would be more readable and in case I'd change middleware Error I wouldn't have to replace it as well in 'x' places in tests.

Cheers,
Tadek

@tj
Copy link
Contributor

tj commented Aug 13, 2012

you can augment the Test.prototype if you want

@tadeuszwojcik
Copy link
Author

but isn't Test module 'internal' in supertest?

@tj
Copy link
Contributor

tj commented Aug 13, 2012

nope it's exported

@tj
Copy link
Contributor

tj commented Aug 13, 2012

nvm I lied, it's not exported right now but we can do that

@gjohnson
Copy link
Contributor

This is exported now. 0956c37

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

3 participants