My app has different modes, each with its own loading times and configurations. One particular mode has a long loading period every time a page is opened which is causing some testing challenges. Currently, I have separate test files for each section of the app, but I want to consolidate them into one file to handle the long wait time more efficiently.
I thought about reusing my existing tests as functions by wrapping them in modules like this:
// test1.js
module.exports = function test1 () {
describe('Test1', function () {
var settings = {}
before(function () {
// do something
})
it('do something', function () {
assert.ok(true)
})
it('do something else', function () {
assert.ok(true)
})
})
}
Then, in another file, I would run each of these functions:
test1 = require('./test1')
test2 = require('./test2')
...
test10 = require('./test10')
describe('Main Test', function () {
test1()
test2()
...
test10()
}
This approach could help me avoid repeating myself, but I'm struggling with how to select specific test functions to run using the command line. Ideally, I would use something like:
wdio wdio/wdio.conf.js --specs wdio/test/spects/browser/test1.js
However, this method doesn't work for my setup. I need a solution that allows me to reuse my tests (the describe blocks) without limiting my ability to choose which ones to run when needed. Is there a better way to approach this? How can I achieve the flexibility I'm looking for?