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

Promised supertest #380

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Promised supertest #380

wants to merge 2 commits into from

Conversation

robinvdvleuten
Copy link

Hi there,

After seeing that there is a PR already since 2014 (#163) and I really like using AVA, Express and some async gallore I thought to open this PR to push some things forward :bowtie:

Now you can do this with the already awesome supertest library;

const test = require('ava')
const request = require('supertest')
const app = require('../lib/app')

test('returns Hello World! on request', async t => {
  await request(app)
    .get('/')
    .expect('Content-Type', /text/)
    .expect('Hello, World!')
    .expect(200)
})

@benesch
Copy link
Contributor

benesch commented Nov 23, 2016

I too got frustrated by SuperTest's unwillingness to support promises, so if you're looking for an immediate solution, I built SuperTest-as-Promised: https://github.com/WhoopInc/supertest-as-promised

@Alex-Mann
Copy link

Any idea on when this will make it into master?

@benesch
Copy link
Contributor

benesch commented Jan 5, 2017

SuperAgent shipped a nearly identical PR, so I think you can actually get this behavior in the latest version of SuperTest!

@lirantal
Copy link

lirantal commented Feb 1, 2017

@robinvdvleuten I don't want to hijack this thread but would you mind explaining how do you setup your tests for expressjs with a db using ava?

@LegNeato
Copy link

LegNeato commented Feb 2, 2017

Relatedly, I just put up a PR if you want to use promises / async functions in expect(). I needed this because my database stuff uses promises and I use async/await.

#402

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

Successfully merging this pull request may close these issues.

5 participants