codeceptjs / CodeceptJS

Supercharged End 2 End Testing Framework for NodeJS
http://codecept.io
MIT License
4.11k stars 724 forks source link

run-workers exits successfully despite test failures when using mocha-junit-reporter #3299

Open examosa opened 2 years ago

examosa commented 2 years ago

Expected

Using the run-workers subcommand will return a non-zero exit code if any tests fail, regardless of reporter used.

Actual

run-workers exits with code 0 even if there are test failures when using mocha-junit-reporter

Console Output

yarn run v1.22.18
$ codeceptjs run-workers --suites 8 --reporter mocha-junit-reporter
CodeceptJS v3.3.0
Running tests in 8 workers...

context
[01]   ✔ Log in as an Administrator in 15873ms
[01]   ✖ Log in as a regular User in 22165ms

  OK  | 0 passed   // 44s
✨  Done in 46.36s.

Process finished with exit code 0

Details

const { register } = require('ts-node')
const { setBrowser, setCommonPlugins, setHeadlessWhen, setTestHost } = require('@codeceptjs/configure')

register({
  projectSearchDir: 'tests'
})

const { users } = require('./tests/config/plugins/autoLogin.ts')

const productionHost = 'https://example.com'

setBrowser(process.env.BROWSER ?? 'chromium')
setHeadlessWhen(process.env.HEADLESS)
setTestHost(process.env.TESTHOST ?? productionHost)
setCommonPlugins()

exports.config = {
  name: 'ui-tests',
  tests: 'tests/ui/**/*.test.ts',
  output: 'tests/output',
  helpers: {
    Playwright: {
      show: true,
      waitForTimeout: 15_000
    }
  },
  plugins: {
    retryFailedStep: {
      enabled: true
    },
    autoLogin: {
      enabled: true,
      inject: 'loginAs',
      users
    }
  },
  mocha: {
    reporterOptions: {
      stdout: 'tests/output/console.log',
      mochaFile: 'tests/output/test-results.xml',
      'mocha-junit-reporter': {
        options: {
          attachments: true
        }
      }
    }
  }
}
github-actions[bot] commented 10 months ago

This issue is stale because it has been open for 90 days with no activity.

exotlv commented 10 months ago

Same issue here. npx codeceptjs run-workers 3 If some tests failed, Im getting this:

[02]   ✖ Тестирование логина и логаута @smoke @C8 in 8302ms
[01]   ✔ Переход в профайл игрока заполнение данных для игрока с регистрацией через телефон @smoke @C27 in 61651ms
[01]   ✔ История выводов @smoke @C16 in 5920ms
  OK  | 0 passed   // 6m
$ echo $?
0

Gitlab runner: green but should be red.

github-actions[bot] commented 7 months ago

This issue is stale because it has been open for 90 days with no activity.