javascript - 将所有测试用例的“beforeEach”放在哪里?
问题描述
这两个测试有什么区别:
beforeEach(doSomething)
describe("i am the only root describe in this test file", () => {
// many test cases...
})
describe("i am the only root describe in this test file", () => {
beforeEach(doSomething)
// many test cases...
})
解决方案
如果放入beforeEach
描述中,它将在此块中的每个测试之前运行。如果把它放在根级别,它会在所有测试文件中的所有测试之前运行。
请参阅https://github.com/demo-drive-learn/mocha-root-pre-hook或查看此演示。
推荐阅读
- python-3.7 - ValueError:无法将字符串转换为浮点数:'ill afb'
- udp - NS3 中的 UDP 吞吐量计算
- pdf - 如何导出具有反转背景和文本颜色的 PDF
- erlang - Ejabberd 的 CPU 使用率很高,并将非活动用户显示为已连接
- c++ - 如何将对象指针数组的大小初始化为动态大小?
- python - 迭代包含特定行中的字符串的某些列 panas
- c++ - 使用花括号而不是括号时 Visual Studio 中断
- c# - 标题中的 WPF 组框多重绑定
- sql-server-ce - SQL CE Compact Edition 工具箱 OutOfMemoryException
- android - 将给定的字符串转换为 byteArrays