首页 > 解决方案 > 我如何为超级测试设置全局配置以在钩子之前在 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))
    })
})

标签: apisupertestsuperagentsupertest-as-promised

解决方案


推荐阅读