我在尝试使用 ts-node 建议调试 Alsatian 测试用例时遇到了一些麻烦 - 因为编写测试用例已经慢到爬行
我正在使用 Alsatian 在 typescript 中编写 selenium 测试用例,我已按照此处提供的说明进行操作: debug asaltian with vs code
但它在 ts-node 上崩溃,说模块 chai 未定义
如果有人可以帮助在 vscode 中逐行进行这些工作和调试,那就太好了
包.json:
{
"dependencies": {
"@types/dotenv": "^4.0.2",
"@types/selenium-webdriver": "^3.0.8",
"alsatian": "^2.0.0",
"dotenv": "^4.0.0",
"selenium-webdriver": "^4.0.0-alpha.1",
"ts-node": "^4.1.0",
"tslib": "^1.8.1",
"typescript": "^2.6.2"
}
}
亚军.ts:
import tapSpec = require('tap-spec');
import { TestSet, TestRunner } from "alsatian";
import { config as dotenv } from 'dotenv';
(async () =>
{
// Load up any pseudo environment variables
dotenv({ path: __dirname + '/../.env' });
// Setup the alsatian test runner
let testRunner = new TestRunner();
let tapStream = testRunner.outputStream;
let testSet = TestSet.create();
testSet.addTestsFromFiles('/**/*/*.spec.ts');
// This will output a human readable report to the console.
tapStream.pipe(tapSpec()).pipe(process.stdout);
// Runs the tests
await testRunner.run(testSet);
})()
.catch(e =>
{
console.error(e);
process.exit(1);
});
这是我之前尝试连接到运行器的旧的 launch.json,此配置启动但未连接。
alasatian github 上提供的另一个失败,因为它抱怨模块 chai 无法在 ts-node 中解析
{
"name": "ANEX.Website.ManagementPortal.Tests",
"type": "node",
"request": "launch",
"runtimeExecutable": "yarn",
"runtimeArgs": [
"run",
"ts-node",
"Tests/runner.ts"
],
"cwd": "${workspaceFolder}/ANEX.Website.ManagementPortal.Tests",
"timeout": 20000,
"protocol": "inspector",
}