api - 我如何为超级测试设置全局配置以在钩子之前在 mocha 中运行?
问题描述
我想知道如何在钩子之前添加一个要在超集中所有阻塞之前运行的方法,以便我可以提取一些需要的信息(令牌、标头、cookie ...)并在之后将其用于所有其他测试
describe('Landing Page test suite', () => {
before(()=>{
})
it('test', (done) => {
request('https://www.example.sh/api/','')
.post('auth/sign_in')
.field('email', 'anythinh@yopmail.com')
.expect(200)
.then(response => {
console.log(response.header)
done();
})
.catch(err => done(err))
})
})
解决方案
推荐阅读
- php - 使用 PHP 提取 PDF 表单数据并提交到 MySQL 数据库
- networking - SNMP 查找正确的 OID 以从 FA-EXT-MIB 获取特定端口数据
- bash - 为什么basename不能用于变量?
- android-recyclerview - 具有自动调整跨度计数的 StaggeredGridLayoutManager
- wpf - WPF 无法从程序集加载类型“AA.HMIRE.UserControls.AAButtonStan”
- mysql - 我无法将 express.js 与 react 连接起来
- ios - 每次用户请求都发送 APNS 设备令牌而不是注册用户是否可以接受?
- javascript - 关于 Redux 更新,如何防止组件更新
- microcontroller - 有没有办法从重置死锁中拯救我的处理器
- html - 图像相对路径不适用于 Angular