失败的 e2e 测试通过 Teamcity 中的构建

Failing e2e tests pass build in Teamcity

我们最近刚刚通过升级节点版本终止了 Teamcity 中的所有 e2e 测试(ooops)。

我确定这是我们能够解决的问题,但它强调了 Teamcity 设置不正确(或者其他问题是错误的)。

正如我所说的,所有测试都失败了,但构建步骤只是说它以代码 0 退出并继续构建成功。

[15:53:13][Step 4/6] 51 specs, 51 failures
[15:53:13][Step 4/6] Finished in 106.981 seconds
[15:53:13][Step 4/6] 
[15:53:13][Step 4/6] closing code: null
[15:53:13][Step 4/6] Process exited with code 0

我们正在使用量角器进行测试,运行它们在构建步骤中使用命令行运行器。

npm run teamcity-e2e

抱歉,如果这很含糊,但希望它对某些人有意义,他们可以为我指明正确的方向:)

干杯..

-- 更多调查后编辑 --

我现在知道问题出在我创建的节点脚本 (teamcity-e2e.js) ...

const exec = require('child_process').exec;

const server = exec('live-server ./dist --port=3000 --no-browser');
const tests = exec('npm run e2e');

tests.stdout.on('data', function(data) {
  console.log(data);
});
tests.stderr.on('data', function(data) {
  console.log(data);
});
tests.on('close', function(code) {
  console.log('closing code: ' + code);
  exec('taskkill /PID ' + server.pid + ' /T /F');
});

虽然我不知道问题出在哪里,但还是请大家帮忙 ;)

太棒了,我已经修好了:)

快速简单的答案是我的节点脚本实际上没有返回退出代码 DOH :)

这是我的固定解决方案...

const exec = require('child_process').exec;

const server = exec('npm run server:test');
const tests = exec('npm run e2e');

tests.stdout.on('data', function(data) {
  console.log(data);
});
tests.stderr.on('data', function(data) {
  console.log(data);
});
tests.on('close', function(code) {
  console.log('closing code: ' + code);
  exec('taskkill /PID ' + server.pid + ' /T /F');
  process.exit(code); //here's the bad boy ;)
});