mocha.js - 测试用例内部的`before`钩子(`it`)
问题描述
mocha 不允许在it
测试用例中使用钩子吗?
我尝试了以下,它似乎永远不会执行:
describe('Array', () => {
before(async () => {
// do some async stuff before any test cases in this suite run
// THIS RUNS OK
});
it('should blah', async () => {
before(async () => {
// do some async stuff just before this test case
// THIS NEVER RUNS!!!!!!!!!!!!!!!!!!!!!!
});
// blah
);
});
before
立即在运行describe
,但before
立即在内部it
不运行。
解决方案
推荐阅读
- react-table - 如何在可扩展的反应表中创建一个包含一个单元格的行?
- microsoft-graph-api - 我们可以使用租户 ID 代替 https://login.microsoftonline.com/tenantId/oauth2/v2.0/token 来调用 Rest Api
- html - BS5 - 在不影响 td 宽度的情况下旋转文本
- freemarker - 将列表作为连接字符串返回
- python - Django 自定义下拉菜单取决于字段类型
- cassandra - Cassandra 中的 ON CONFLICT 运算符
- python - 导入包时如何动态设置根项目路径
- java - 如何在 Selenium 脚本的持续执行过程中使用扩展?
- docker-compose - 使用 Traefik 和 docker-compose 的端口转发问题
- python - 用于确定文本照片所需旋转角度的 Python 包