const response = {
data: {
user: {
profile: { name: "Alice" }
}
}
};// Safe access with ?.:
const avatarUrl = response?.data?.user?.profile?.avatar ?? "default-avatar.png";
// Nullish coalescing (??) only replaces null or undefined (not 0 or false):
const timeout = customConfig.timeout ?? 30000;
// utils/locatorHelpers.js
export const getRowSelector = (id) => tr[data-id="${id}"];// In test file:
import { getRowSelector } from "../utils/locatorHelpers.js";