GeezerVison is showing github.com — Add: Cucumber/Gherkin step detection and assertion logging for test observability by prathams-cmd · Pull Request #1053 · browserstack/browserstack-cypress-cli
Conversation
What is this about?
Assertions logs and Cucumber/Gherkin step definitions were not showing up in observability log. I used Cypress log:changed event to detect these. I used createdAt and updatedAt timestamps and pushed COMMAND_START and COMMAND_END events for assertions logs and passed it as test_observability_command. The functions for showing cucumber step definitions were already placed I just detected them and passed it as test_observability_step.
Related Jira task/s
Automation cases to add
it('displays two todo items by default', () => {
cy.log('Verifying default todo items are displayed')
// should (length)
cy.get('.todo-list li').should('have.length', 2)
// expect (first item text)
cy.get('.todo-list li').first().then(($first) => {
expect($first.text()).to.equal('Pay electric bill')
})
// assert (last item text)
cy.get('.todo-list li').last().then(($last) => {
assert.include($last.text(), 'Walk the dog', 'Last item contains expected text')
})
})
import { Given, When, Then, defineStep } from "@badeball/cypress-cucumber-preprocessor";
import "cypress-xpath";
import Login from "../pages/login.page";
import Purchase from "../pages/purchase.page";
import Orders from "../pages/orders.page";
const login = new Login();
const purchase = new Purchase();
const orders = new Orders();
Given("I navigate to website", () => {
cy.visit(Cypress.config().baseUrl + "signin");
});
defineStep("I wait for the page to load", () => {
cy.document().its("readyState").should("eq", "complete");
});
When("I SignIn as {string} with {string} password", (username, password) => {
login
.username()
.should("be.visible")
.click({ force: true })
.type(username + "{enter}");
login
.password()
.click({ force: true })
.type(password + "{enter}");
login.logInButton().click();
});
When("I add three products to cart", () => {
purchase.item1().click({ force: true });
purchase.item2().click({ force: true });
purchase.item3().click({ force: true });
});
When("I click on Buy Button", () => {
purchase.buyButton().click({ force: true });
});
When(
"I enter shipping details {string}, {string}, {string}, {string} and {string}",
(first, last, address, province, pincode) => {
cy.get("#firstNameInput").type(first);
cy.get("#lastNameInput").type(last);
cy.get("#addressLine1Input").type(address);
cy.get("#provinceInput").type(province);
cy.get("#postCodeInput").type(pincode);
}
);
When("I click on Checkout Button", () => {
orders.checkout().click();
cy.contains("Continue ").click();
});
When("I click on {string} link", (link) => {
cy.contains(link).click();
});
Then("I should see elements in list", () => {
cy.xpath("/html/body/div/main/div/div/div/div[2]/div/div[2]")
.children("div")
.should("have.length", 3);
cy.pause();
});
Code changes to check
Please ensure that the following guidelines are being followed
- Spread operator is not used.
- Used syntax is supported by node 12+. Ex. No
? operator.
Checklist
- Has it been approved by a member of your team?
- Has it been tested with obfuscation locally? Refer this.
- Have release notes been added to nodejs.yml?
- Required automation cases are added in description.
PR Validations
SCA: Comment RUN_SCA to trigger SCA check.
Run Tests: Comment RUN_TESTS to trigger tests.
Note: Make sure to pull the latest main branch changes in your branch before running the check.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
prathams-cmd
changed the title
SDK-4928: Cypress - missing assertion-level logs in the new Dashboard
Add: Cucumber/Gherkin step detection and assertion logging for test observability
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test with some old versioins as well.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
if (shouldSkipCommand(command)) {
|
|
|
return;
|
|
|
}
|
|
|
// Cypress.on('log:added', (log) => {
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
|
|
|
const keyword = (attrs.name || '').trim();
|
|
|
if (STEP_KEYWORDS.includes(keyword.toLowerCase())) {
|
|
|
const text = (attrs.message || '').replace(/\*\*/g, '');
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove if not breaking anything
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
if (!Cypress.env('BROWSERSTACK_O11Y_LOGS')) return;
|
|
|
if (!attrs) return;
|
|
|
if (attrs.state !== 'passed' && attrs.state !== 'failed') return;
|
|
|
if (parseInt(Cypress.version.split('.')[0], 10) >= 13) {
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the timestamp field is not present do early return, no need to check cypress version.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
osho-20
osho-20 left review comments
At least 1 approving review is required to merge this pull request.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|