I'm trying to spy on the global google analytics method:
describe("google analytics spy", () => {
let spy;
beforeEach(() => {
browser.url("http://...");
let $window = browser.execute(() => window);
spy = spyOn($window, "ga");
});
it("should invoke the ga function", () => {
expect(spy).toHaveBeenCalled();
});
});
Unfortunately, the returned window object is some sort of reference without any of its properties or methods:
{
sessionId: 'somehash...",
value: [],
_status: 0
}
I can get a ga
method by doing:
let $ga = browser.execute(() => window.ga);
which returns:
{ sessionId: '34dcfbd74e7eafac2eedc03ea1709858',
value:
{ L: 1520951932160,
N: {},
P: [ [Object] ],
answer: 42,
create: {},
da: {},
getAll: {},
getByName: {},
h: { t0: [Object] },
j: {},
loaded: true,
remove: {} },
_status: 0 }
yet without any parent context, I am unable to spy on it. What am I missing?
Aucun commentaire:
Enregistrer un commentaire