/** * HeroUnion测试用例 * 执行此测试之前,请先启动主程序,在根目录执行命令:npm start */ import test from 'node:test'; import assert from 'node:assert'; import axios from 'axios'; import common from '../common.mjs'; import HeroUnion from '../heroUnion.mjs'; test('Hero onboard test', async (t) => { let params = { name: 'test_hero', description: 'Hero test 测试爬虫', status: 'idle', timestamp: common.getTimestampInSeconds(), country: 'cn', lang: 'zh' }; let api = 'http://127.0.0.1:8080/api/onboard/'; const response = await axios.post(api, params, {timeout: 5000}); console.log(response.data); assert.equal(response.status, 200); assert.equal(response.data.code, 1); }); test('HeroUnion stats test', async (t) => { let api = 'http://127.0.0.1:8080/api/stats/'; const response = await axios.get(api, {timeout: 5000}); console.log(response.data); assert.equal(response.status, 200); });