Syntax
Tip: Click the eyeball icon () in code blocks to toggle the visibility of the hidden lines.
Click here to view Example tests for the following syntax.
If you do not use any Qase syntax, the reporter uses the title from the fixture
and test
functions to make the Suite and Test case titles while publishing results.
Example Spec file
import { test } from 'testcafe';
import { qase } from 'testcafe-reporter-qase/qase';
fixture`Simple tests`
.page`http://devexpress.github.io/testcafe/example/`;
test('Simple Test', async (t) => {
await t.expect(true).ok();
});
Import Statement
Add the following statement at the beginning of your spec file, before any tests.
import { qase } from 'testcafe-reporter-qase/qase';
Now, let’s take a closer look at each of the Qase functions.
Qase ID
To associate an ID to your Test Case use qase.id
function. This function accepts a single integer representing the test’s ID in Qase.
Only one Qase Id can be linked to a test.
test.meta(
qase.id(1).create();
)
('Test with QaseID success', async () => {
//Test logic here..
});
Qase Title
The qase.title()
method is used to set the title of a test case, both when creating a new test case from the result, and when updating the title of an existing test case - if used with qase.id()
.
test.meta(
qase.title('This title will appear, in Qase').create()
)('this title will not appear in Qase', async(t)=>{
// Test logic here
});
To update a Qase test case’s title from code, you must enable “Update test cases” in your project’s run settings.
If you don’t explicitly set a title using the qase.title
method, the title specified in the test
definition will be used for new test cases.
However, if the qase.title
method is defined, it always takes precedence and overrides the title from the test
definition
Steps
The reporter uses the title from the qase.step
function as the step title. By providing clear and descriptive step names, you make it easier to understand the test’s flow when reviewing the test case.
Additionally, these steps get their own result in the Qase Test run, offering a well-organized summary of the test flow. This helps quickly identify the cause of any failures.
test('test', async (t) => {
await qase.step('Step 1', async (s1) => {
await s1.step('Step 1.1', async (s11) => {
await s11.step('Step 1.1.1', async (s111) => {
s111.attach({ name: 'attachment.txt', content: 'Hello, world!', contentType: 'text/plain' });
//Step logic goes here;
});
});
//Step logic here..
});
// Step logic here..
});
Fields
Currently, you can define description
, pre & post conditions
, and fields like severity
, priority
, layer
with this method, allowing you to specify and maintain the context of the case, all directly from within your code.
const q = qase.fields({
'severity':'major',
'priority':'high',
'description':'This is a test case with qase.fields'
}).create();
test.meta(q)('Test Case with fields set using qase.fields', async () => {
//test logic here..
});
test.meta(
qase.fields({
'description': 'Test description',
'preconditions': 'Some precondition',
'postconditions':'Some postcondition',
'layer':'unit'
}).create()
)('Test with fields failed', async() => {
//test logic here..
});
Parameters
Parameters are a great way to make your tests more dynamic, reusable, and data-driven. By defining parameters in this method, you can ensure only one test case with all the parameters is created in your Qase project, avoiding duplication.
test.meta(
qase.parameters({ param1: 'value1', param2: 'value2', param3:'value3' }).create();
)
('simple test with Single & Group parameters', async () => {
//test logic here
});
test.meta(
qase.groupParameters({param1:'value1', param2:'value2'}).create();
)
('simple test with group parameter', async () => {
//test logic here
});
Attach
Before using qase.attach
method. You need to set
"uploadAttachments":true
inside your qase.config.json
Configuration file.
This method can help attach one, or more files to the test’s result. You can also add the file’s contents, directly from code. For example:
test("Test with file attachment success", async () => {
qase.attach({ paths: ["path of file"] });
// Test Logic here..
});
test("Test with content attachment success", async () => {
qase.attach({
name: "log.txt",
content: "Hello, World!",
type: "text/plain",
});
//Test logic goes here..
});
Ignore
If this method is added, the reporter will exclude the test’s result from the report sent to Qase. While the test will still executed by testcafe, its result will not be considered by the reporter.
test.meta(
qase.ignore().create();
)('Test with ignore', async t => { //This test case will be Ignored as qase.ignore is added.
//Test Logic here..
});
test('simple test', async () => { // This test case will be shown in the test run on Qase
//Test Logic here..
});