cucumber-mink
cucumber-mink copied to clipboard
Use cucumber mink from within a node javascript file
I want to run cucumber mink using gulp (instead of from the command line). So to do this, I need to just run mink from a javascript file.
I have tried doing:
const cucumber = require('cucumber');
const Mink = require('cucumber-mink');
Mink.init(cucumber);
and
const { defineSupportCode } = require('cucumber');
defineSupportCode((cucumber) => {
const Mink = require('cucumber-mink');
Mink.init(cucumber);
});
However, both times I receive the same error:
TypeError: Path must be a string. Received undefined
at assertPath (path.js:28:11)
at Object.relative (path.js:1247:5)
at getDefinitionLineAndUri (/Users/lishmanm/Documents/workspace/cucumber-test/node_modules/cucumber/lib/support_code_library_builder/define_helpers.js:146:28)
at Object.BeforeAll (/Users/lishmanm/Documents/workspace/cucumber-test/node_modules/cucumber/lib/support_code_library_builder/define_helpers.js:84:34)
at Mink.registerHooks (/Users/lishmanm/Documents/workspace/cucumber-test/node_modules/cucumber-mink/src/mink.js:180:14)
at Mink.init (/Users/lishmanm/Documents/workspace/cucumber-test/node_modules/cucumber-mink/src/mink.js:80:10)
at Object.<anonymous> (/Users/lishmanm/Documents/workspace/cucumber-test/test.js:3:6)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:575:3
Is it possible to run cucumber mink from a javascript file rather than the command line? Is there something I am missing/not understanding here?
Hello @MattLish
If you wish to execute cucumber from your own .js
file, you'll have to mimic the initialisation procedure here: https://github.com/cucumber/cucumber-js/blob/master/src/cli/index.js
And then inject mink support code inside this procedure.
hope this helps
Hi, I want to add mink to my angular 5 project using protractor-cucumber-framework. I've put a 'onPrepare' in my protractor.conf.js that initializes mink & registers itself to cucumber, and I get the same error as MatLish.
onPrepare() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
const Mink = require('cucumber-mink');
const parameters = {
driver: {
logLevel: 'silent',
desiredCapabilities: {
browserName: 'chrome',
},
port: 9515,
},
};
const cucumber = require('cucumber');
Mink.configure(parameters);
Mink.init(cucumber);
}
On the homepage of mink: http://cucumber-mink.js.org/ it's described how to run with cucumber.js support code, but still uses the deprecated method 'defineSupportCode' which I replaced with the new approach (see my code fragment).
It's not clear to me how to mimic the initialisation procedure myself (cfr your response above). Why isn't Mink.init doing that? What's that paragraph describing on the homepage then?
@pmestrum where you ever able to find a viable solution for new(er) versions of protractor? If so, would you mind sharing a snippet?
EDIT: note I eventually ended up porting this as it was easier than working around not using protractor natively -- https://github.com/matmar10/protractor-cucumber-mink