1 Star 0 Fork 19

7040210/NeteaseCloudMusicApi

forked from Sake/NeteaseCloudMusicApi 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
server.test.js 920 Bytes
一键复制 编辑 原始数据 按行查看 历史
binaryify 提交于 2023-09-09 18:15 . fix: 单元测试问题修复
const fs = require('fs')
const path = require('path')
const tmpPath = require('os').tmpdir()
/** @type {import("express").Express & serverMod.ExpressExtension} */
let app
if (!fs.existsSync(path.resolve(tmpPath, 'anonymous_token'))) {
fs.writeFileSync(path.resolve(tmpPath, 'anonymous_token'), '', 'utf-8')
}
const serverMod = require('./server')
before(async () => {
app = await serverMod.serveNcmApi({})
if (app.server && app.server.address) {
const addr = app.server.address()
if (addr && typeof addr === 'object' && 'port' in addr) {
global.host = `http://localhost:${addr.port}`
return
}
}
throw new Error('failed to set up host')
})
after((done) => {
if (app.server) {
app.server.close(done)
return
}
throw new Error('failed to set up server')
})
fs.readdirSync(path.join(__dirname, 'test')).forEach((file) => {
require(path.join(__dirname, 'test', file))
})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/7040210/NeteaseCloudMusicApi.git
git@gitee.com:7040210/NeteaseCloudMusicApi.git
7040210
NeteaseCloudMusicApi
NeteaseCloudMusicApi
master

搜索帮助