williamcodes
williamcodes

Reputation: 7236

beforeEach with suite syntax for mocha tests

I'm coming from RSpec style before(:each) blocks and am working on a javascript project that uses Mocha's suite instead of describe. It seems like Mocha actually has a beforeEach that does exactly what I need, but it doesn't work because we're using suite instead of describe. The team doesn't want to change syntax. How do I run code before each test?

Upvotes: 1

Views: 135

Answers (1)

wjohnsto
wjohnsto

Reputation: 4463

You should be able to use setup, teardown, suiteSetup, and suiteTeardown.

Reference: https://github.com/mochajs/mocha/issues/310

Upvotes: 2

Related Questions