javascript - 摩卡异步测试没有被调用
问题描述
我对 mocha 比较陌生,并尝试运行异步测试。但是在产生测试结果之前运行 after 方法。我一定做错了什么,但我找不到什么。
任何帮助表示赞赏
这是我的代码
before( done => {
server.start()
.then(() => {
done()
})
})
after( done => {
server.stop()
.then(() => {
done()
})
})
it('should start webservice api and not throw', done => {
const ws = new Webservice('ws', 1, 'test')
ws.start()
.then(axios.post(`http://localhost:${process.env.WORKFLOW_PORT}/test`))
.then(ws.stop())
.then(() => {
done()
})
})
it('should start 2 webservice api and not throw', done => {
const ws = new Webservice('ws', 1, 'test2')
const ws2 = new Webservice('ws', 2, 'test3')
ws.start()
.then(ws2.start())
.then(axios.post(`http://localhost:${process.env.WORKFLOW_PORT}/test2`))
.then(axios.post(`http://localhost:${process.env.WORKFLOW_PORT}/test3`))
.then(ws.stop())
.then(ws2.stop())
.then(() => {
done()
})
})````
解决方案
推荐阅读
- r - 如何在 R 胶水语法中设置“na.rm = TRUE”
- google-cloud-platform - Google Cloud Build 未能检索到 Github 存储库
- authentication - 如何配置 axios 以使用 auth 请求 WebAPI?
- python - 如何用数据框列中的字符串列表替换单个字符串
- vue.js - Vuetify数据表如何使用主题颜色设置全选列的背景颜色?
- javascript - 如何替换javascript中所有出现的字符串?
- javascript - 关于英国政府新的外出就餐帮助计划网站的问题
- linux - 如何在 windows 和 linux 上为 react-native 项目运行 detox?
- c# - 如何在 CIL (MSIL)“调用实例 void valuetype [..type]”中返回或保存值?(通用中间语言)
- javascript - 表单中的下拉列表在使用节点 js 提交后清除值