MinervaNeue/tests/selenium/features/support/world.js
Jan Drewniak 018d436bfe Ensure each api call creates a new instance of MWBot
As a hold-over from a previous porting attempt, thw World.js file
(a cucumber.js convention) exported an instance of MWBot. This
instance was used in several tests, however, since MWBot had been
instantiated multiple times since then, the original edit token
was invalid, causing several tests to fail.

Bug: T224947
Change-Id: I56c06600c43d53bbc4e103d446a1de7a52c2cfad
2019-06-06 13:33:54 +02:00

28 lines
899 B
JavaScript

/**
* World
*
* World is a function that is bound as `this` to each step of a scenario.
* It is reset for each scenario.
* https://github.com/cucumber/cucumber-js/blob/master/docs/support_files/world.md
*
* Contrary to Cucumber.js best practices, this `MinervaWorld` is not being
* bound to scenarios with the `setWorldConstructor` like this:
*
* setWorldConstructor(MinervaWorld);
*
* Instead, it acts as a simple function that encapsulates all dependencies,
* and is exported so that it can be imported into each step definition file,
* allowing us to use the dependencies across scenarios.
*/
const mwCorePages = require( '../support/pages/mw_core_pages' ),
minervaPages = require( '../support/pages/minerva_pages' );
function MinervaWorld() {
/* pageObjects */
Object.assign( this, mwCorePages );
Object.assign( this, minervaPages );
}
module.exports = new MinervaWorld();