简体   繁体   English

beforeEach具有用于Mocha测试的套件语法

[英]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 . 我来自RSpec样式的before(:each)块,正在使用Mocha suite而不是describe的JavaScript项目中进行工作。 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 . 看起来Mocha实际上确实具有一个beforeEach可以完全满足我的需要,但是它不起作用,因为我们使用suite而不是describe The team doesn't want to change syntax. 团队不想更改语法。 How do I run code before each test? 每次测试前如何运行代码?

You should be able to use setup , teardown , suiteSetup , and suiteTeardown . 您应该能够使用setupteardownsuiteSetupsuiteTeardown

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM