import { setWorldConstructor } from "cucumber";
class CustomWorld {
constructor() {
this.cwd = process.cwd();
}
}
setWorldConstructor(CustomWorld);
TypeError: Arguments to path.resolve must be strings
at Object.exports.resolve (http://localhost:63862/__cypress/tests?p=cypress/integration/testrail/login/login.feature-179:78415:13)
at Object.exports.relative (http://localhost:63862/__cypress/tests?p=cypress/integration/testrail/login/login.feature-179:78476:18)
at getDefinitionLineAndUri (http://localhost:63862/__cypress/tests?p=cypress/integration/testrail/login/login.feature-179:26986:27)
at buildStepDefinitionConfig (http://localhost:63862/__cypress/tests?p=cypress/integration/testrail/login/login.feature-179:26926:7)
at SupportCodeLibraryBuilder.defineStep (http://localhost:63862/__cypress/tests?p=cypress/integration/testrail/login/login.feature-179:27112:79)
at Object.25.../screens.json (http://localhost:63862/__cypress/tests?p=cypress/integration/testrail/login/login.feature-179:1742:20)
at o (http://localhost:63862/__cypress/tests?p=cypress/integration/testrail/login/login.feature-179:1:265)
at http://localhost:63862/__cypress/tests?p=cypress/integration/testrail/login/login.feature-179:1:316
at Suite.<anonymous> (http://localhost:63862/__cypress/tests?p=cypress/integration/testrail/login/login.feature-179:52:1)
at Object.1./Users/thomasghenry/code/.../cypress/support/step_definitions/cypress/integration/examples/actions.spec.js (http://localhost:63862/__cypress/tests?p=cypress/integration/testrail/login/login.feature-179:29:3)
at o (http://localhost:63862/__cypress/tests?p=cypress/integration/testrail/login/login.feature-179:1:265)
at r (http://localhost:63862/__cypress/tests?p=cypress/integration/testrail/login/login.feature-179:1:431)
at http://localhost:63862/__cypress/tests?p=cypress/integration/testrail/login/login.feature-179:1:460
Uncaught TypeError: Cannot set property 'World' of undefined
at setWorldConstructor (http://localhost:64786/__cypress/tests?p=cypress/integration/testrail/login/login.feature-742:27066:28)
at Object.<anonymous> (http://localhost:64786/__cypress/tests?p=cypress/integration/testrail/login/login.feature-742:1732:35)
at Object.25./Users/thomasghenry/code/duke/tams/tams-react/node_modules/@cypress/browserify-preprocessor/node_modules/@babel/runtime/helpers/classCallCheck (http://localhost:64786/__cypress/tests?p=cypress/integration/testrail/login/login.feature-742:1761:4)
at o (http://localhost:64786/__cypress/tests?p=cypress/integration/testrail/login/login.feature-742:1:265)
at http://localhost:64786/__cypress/tests?p=cypress/integration/testrail/login/login.feature-742:1:316
at Suite.<anonymous> (http://localhost:64786/__cypress/tests?p=cypress/integration/testrail/login/login.feature-742:52:1)
at Object.1./Users/thomasghenry/code/duke/tams/tams-react/cypress/support/step_definitions/cypress/integration/examples/actions.spec.js (http://localhost:64786/__cypress/tests?p=cypress/integration/testrail/login/login.feature-742:29:3)
at o (http://localhost:64786/__cypress/tests?p=cypress/integration/testrail/login/login.feature-742:1:265)
at r (http://localhost:64786/__cypress/tests?p=cypress/integration/testrail/login/login.feature-742:1:431)
at http://localhost:64786/__cypress/tests?p=cypress/integration/testrail/login/login.feature-742:1:460
Hey @channel, I know running a single cucumber scenario gives you so much trouble in VSCode- you need to tag a scenario specifically and then call that tag explicitly from CLI. Very troublesome, right?
What if, you could just right-click a scenario and execute that? What if you just run a whole feature file just by clicking a button? Sounds good, right.
I have published a beta version of that dream just now. I hope you will play with it and help me enhance it by finding bugs.
Here it is: https://marketplace.visualstudio.com/items?itemName=AbhinabaGhosh.cucumberquick
node index.js
at the end of the script since I am following this, https://www.npmjs.com/package/cucumber-html-reporter. I want to try calling node index.js
from afterall but I don't know how to do that yet
Hello everyone, I hope this is the right place to ask this question. I'm running @wdio/cucumber-framework, but maybe those of you familiar with cucumber-js will be able to see the problem. I've defined and set a custom World constructor, and it is being re-constructed with each scenario as expected, as I can see by a console.log("Constructing world") inside the custom constructor function. However: Each scenario is able to somehow modify the subsequently constructed object rather than having it re-constructed with defaults as specified, and the modifications don't get overwritten for the new scenario. world.js looks like this:
const options = {loginBusinessOptions: {
login: "abc",
password: "xyz"
}};
function CustomWorld() {
console.log("Constructing world");
console.log("options.loginBusinessOptions is " + JSON.stringify(options.loginBusinessOptions));
this.nav = {};
// this.context=options;
this.context=Object.assign(options);
}
export default CustomWorld
Observe output of running a scenario twice, where the first scenario sets "this.context.loginBusinessOptions.login='new login' instead of its original value 'abc' as set in the 'options' object above, showing that the 'options' object has been overwritten by the 1st scenario's setting of this.context.loginBusinessOptions.login.
This happens whether the custom constructor simply sets 'this.context=options' or does an Object.assign to prevent the two objects being treated as the same object.
[0-0] Constructing world
[0-0] options.loginBusinessOptions is {"login":"abc","password":"xyz"}
[0-0] ***this.context.loginBusinessOptions is {"login":"abc","password":"xyz"}
Constructing world
options.loginBusinessOptions is {"login":"new login","password":"xyz"}
***this.context.loginBusinessOptions is {"login":"new login","password":"xyz"}
There is a reproducible example of this here: https://github.com/osmolyar/wdio_cucumber_world_not_reinitialized . or - if this does not happen with cucumber-js, it can be narrowed down to a @wdio/cucumber-framework issue. Thanks in advance for any guidance.