The Branch Web SDK for deep linking and attribution. Once initialized, the Branch Web SDK allows you to create and share links with a banner (web only), over SMS, or your own methods by generating deep links. It also offers event tracking, access to referrals, and management of credits.
Hello,
we're using custom landing page functionality instead of "Branch-hosted SMS Landing Page" and would like to cover our page with e2e cypress.io powered tests. Cypress offers HTTP request interception/stubbing functionality so I tried to leverage that to simulate Branch API responses when the SDK calls https://api2.branch.io/v1/open with following code:
cy.intercept('POST', 'https://api2.branch.io/v1/open', {
statusCode: 200,
body: {
"session_id":"123456",
"identity_id":"456789",
"link":"https://get.my.app/a/key_live_123?%24identity_id=456",
"data":"{\"$marketing_title\":\"marketing title\",\"~creation_source\":1,\"+click_timestamp\":1659094797,\"~feature\":\"feature\",\"+match_guaranteed\":true,\"~tags\":[\"tag1\"],\"~marketing\":true,\"+clicked_branch_link\":true,\"~id\":1234567890,\"$one_time_use\":false,\"~campaign\":\"campaign 1\",\"+is_first_session\":false,\"~referring_link\":\"https://get.my.app/test-link\",\"~channel\":\"channel\"}","browser_fingerprint_id":"1234567890","has_app":false,"referring_link":"/c/test-link?__branch_flow_id=1234567"}
});
cy.visit('/landing-page/?_branch_match_id=123456789&_branch_referrer=abc123');
// verify the UI was rendered well based on Branch link data
The test works well when invoked for the first time, but the problem is with subsequent runs or when there's more than single test. After the initialization Branch SDK somehow stays initialized for subsequent tests or test runs so https://api2.branch.io/v1/open is never called again. branch.init() returns no data thus the page behaves like it wasn't invoked by a Branch-powered link. I tried to reset global branch variable using following code, but it didn't help:
Is there any official way how to uninitialize Branch SDK on a web page or a "recipe" on how to write e2e tests for Branch SDK powered websites, please?
Hello, we're using custom landing page functionality instead of "Branch-hosted SMS Landing Page" and would like to cover our page with e2e cypress.io powered tests. Cypress offers HTTP request interception/stubbing functionality so I tried to leverage that to simulate Branch API responses when the SDK calls https://api2.branch.io/v1/open with following code:
The test works well when invoked for the first time, but the problem is with subsequent runs or when there's more than single test. After the initialization Branch SDK somehow stays initialized for subsequent tests or test runs so
https://api2.branch.io/v1/open
is never called again.branch.init()
returns no data thus the page behaves like it wasn't invoked by a Branch-powered link. I tried to reset global branch variable using following code, but it didn't help:Is there any official way how to uninitialize Branch SDK on a web page or a "recipe" on how to write e2e tests for Branch SDK powered websites, please?