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

Add support for before() and after()? #21

Open
af opened this issue Oct 12, 2016 · 1 comment
Open

Add support for before() and after()? #21

af opened this issue Oct 12, 2016 · 1 comment

Comments

@af
Copy link
Contributor

af commented Oct 12, 2016

Painless already has beforeEach() and afterEach(), but for some cases before/after are preferable. For example I'm writing some integration tests, and I want to spin up an http server before the test group, and then close it when all the tests have run. Starting/stopping with every test slows down the tests considerably.

Does this sound like a worthwhile feature addition?

@af
Copy link
Contributor Author

af commented Oct 12, 2016

So I realized after creating this issue that tests are executed in the order they're written. So while before() and after() are not available, you can "fake" them with something like:

const {createGroup} = require('painless')
const test = createGroup()

test('setup', (done) => {
    // Do test setup here
    done()
})

// real tests happen here

test('teardown', (done) => {
    // do teardown stuff here
    done()
})

Leaving this open so others can chime in, but this is working for me for the time being.

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