qase-tms / qase-javascript

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

[qase-javascript] custom reporter #698

Open Qvatra opened 21 hours ago

Qvatra commented 21 hours ago

Hello, I'm trying to create simple plugin for Vitest tests to send to qase test result so that it will be visible in corresponding (by id) testcase run history.

so far I have this but it doesnt add results in testcase run history:


// Use loadConfig to load environment and other settings
const config = (new ConfigLoader({}, ['src/plugins/qase.config.json'])).load();

// Extract API token and project from loaded config
const qaseApiToken = config.testops?.api.token;
const projectCode = config.testops?.project;

// Initialize QaseReporter using the config
const reporterOptions = {
    ...config,
    apiToken: qaseApiToken,
    projectCode,
};

const reporter = new QaseReporter(reporterOptions);

const result = {
    case_id: 9,
    title: 'Sample Test',
    execution: {
        status: 'passed'
    },
    status: 'passed',
};
await reporter.addTestResult(result);

and config is the following:

    "mode": "testops",
    "fallback": "report",
    "debug": true,
    "environment": "local",
    "captureLogs": false,
    "report": {
        "driver": "local",
        "connection": {
            "local": {
                "path": "./build/qase-report",
                "format": "json"
            }
        }
    },
    "testops": {
        "api": {
            "token": "123",
            "host": "qase.io"
        },
        "run": {
            "title": "Regress run",
            "description": "Regress run description",
            "complete": true
        },
        "defect": false,
        "project": "INSPIRE",
        "batch": {
            "size": 100
        }
    }
}

Is there a guide/docs on how I can achieve this with qase-javascript lib? can you please guide me a bit?

gibiw commented 5 hours ago

Hi!

You can see an example of any of our reporters. For example, Playwright: https://github.com/qase-tms/qase-javascript/blob/main/qase-playwright/src/reporter.ts

When using QaseReporter you need to call the following methods in the given order: