Basic Usage
Learn the core functionality of QAFlow Reporter
Basic Usage
This guide covers the core functionality of QAFlow Reporter and shows you how to use it in your tests.
Importing the Reporter
QAFlow Reporter provides a singleton instance that you can import directly:
Creating a Test
To start reporting, you first need to create a test:
The createTest
method makes this the current active test. All subsequent steps will be associated with this test until you call end()
or create another test.
Adding Test Steps
After creating a test, you can add steps to it:
Step Parameters
The step
method accepts the following parameters:
name
: String name of the stepfn
: Function to execute or a boolean valueoptions
: (Optional) Object with additional options:description
: Additional details about the stepscreenshot
: Base64-encoded screenshot dataskipped
: Whether to mark the step as skipped
Different Ways to Create Steps
Function Execution
Direct Boolean Result
With Screenshot
Skipped Step
Step Results
Each step returns an object with:
step
: The step information including statusresult
: The value returned by the step function (if any)
Ending a Test
When you're done adding steps, end the test to finalize the report:
The end
method:
- Calculates the final test status
- Sends all test data to the QAFlow API
- Returns a summary of the test results
The returned results
object contains:
name
: Test namesummary
: Summary of test results (total, passed, failed, skipped steps)duration
: Total test duration in milliseconds
Complete Example
Here's a complete example showing the entire workflow:
Error Handling
QAFlow Reporter automatically handles errors in your steps:
When an error occurs:
- The step is marked as FAILED
- The error message and stack trace are captured
- Execution continues to the next step
It's good practice to wrap your test in a try/catch block:
Next Steps
Now that you understand the basics, check out:
- Examples for integration with specific frameworks