I have several suites and in each one some spec files.
What I noticed is that after wdio
runs all tests in any spec file, it closes the browser and opens a fresh instance of the browser. Even the local storage is removed in this case.
So I have a hard time finding a place to define a variable that it's value persists throughout all tests.
I tried defining an array on top of my wdio.base.conf.js
file.
let globalStuff = []
const config = { ...
beforeTest: function (test) {
globalStuff.push(Math.random())
},
afterSession: function (config, capabilities, specs) {
console.log(globalStuff)
},
}
Observation: The values of globalStuff
are reseted each time and only contains x items (x is the number if it
tests in a spec file)
Expectation: The values of globalStuff
should be an aggregation of all pushed values.