qase-tms / qase-javascript

Qase TMS JavaScript SDK
https://developers.qase.io
49 stars 43 forks source link

Disable defects creation when automated tests fails #390

Closed hex0cter closed 1 year ago

hex0cter commented 1 year ago

Qase plugin for playwright creates a defect whenever an automated test fails. There is very useful in some scenarios but can also create a lot of noise if you don't need it. In our case we use defect only when we run the manual tests. When the automated tests fail, we have tons of other ways to keep track of them. Right now the plugin creates a defect whether you want it or not, which really mess up with the defects people created manually.

Could you please make this behaviour optional?

angrarof commented 1 year ago

I think the same!

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

kunihiko-sasaki commented 1 year ago

I would like to have it too.

michaelhays commented 11 months ago

This should definitely be built-in, but in the meantime, you can use a Playwright custom reporter to mark all tests results with defect: false:

playwright/qaseReporter.ts

import PlaywrightReporter from 'playwright-qase-reporter'

// @ts-expect-error: ESM stuff
class PlaywrightQaseReporter extends PlaywrightReporter.default {
  public async onEnd(): Promise<void> {
    // @ts-expect-error: Not sure how to type this
    this.resultsToBePublished = this.resultsToBePublished.map((result) => ({
      ...result,
      defect: false,
    }))

    await super.onEnd()
  }
}

export default PlaywrightQaseReporter

(^ I needed to extend from PlaywrightReporter.default, you may or may not need the .default)

playwright.config.ts

import { defineConfig } from '@playwright/test'

export default defineConfig({
  reporter: [
    ['list'],
    [
      './playwright/qaseReporter.ts',
      {
        apiToken: process.env.QASE_API_TOKEN,
        logging: true,
        projectCode: '<project>',
        runComplete: true,
        uploadAttachments: true,
      },
    ],
  ],
  ...
})

(^ Be sure to replace <project> with your project code)

michaelhays commented 5 months ago

FYI, it looks like this behavior was removed in version 2, so test failures won't automatically create defects :+1: