Murray Hopkins
2018-07-31 14:09:06 UTC
Hi.
I use nw.js (node + chromium) to build desktop apps for Windows, OSX,
Linux.
I want to use CucumberJS to run my Gherkin feature files within the nw.js
app.
I can run features via the CLI. I can run features via execFile() child
process. But what I want to do is to run the tests in the nw.js node
context directly so I can test my app. Note that I am not interested in
testing the DOM. I want to test the vanilla JS business logic that is
running in this node context. It does not need the DOM or UI.
So, I set up the files as per the instructions here:
https://github.com/cucumber/cucumber-js/blob/master/docs/nodejs_example.md
Then I created a tests.js script that runs when the app starts as below.
What I cant work out is how to invoke CucumberJS directly. What method do I
call and with what params?
console.log('Start tests');
/*
Re:
https://github.com/cucumber/cucumber-js/blob/master/docs/nodejs_example.md
I have created the following files as per that nodejs_example.md page:
features/simple_math.feature
features/support/world.js
features/support/steps.js
That page then says:
Run ./node_modules/.bin/cucumber-js
*/
// I can do this and it runs in the child process. All good.
execFile(
'node_modules/.bin/cucumber-js',
['simple_math', '-f', 'json:' + toJsonFile],
function (error, stdout, stderr) {
// Run the next action.
// ie process the generated json file
}
);
// But I want to run it in THIS node process so I can test the simple_math
feature.
// Of course, in my real app I want to test its JS classes and methods etc,
not just a simple feature.
// So, the World needs to be the JS in this node context.
const cucumber = require('cucumber');
// What I am looking for is the equivalent of this pseudo code.
cucumber.run(
['simple_math', '-f', 'json:' + toJsonFile],
function (error) {
if (!error) {
// Run the next action.
// ie process the generated json file
}
}
);
I have spent hours trying to work this out to no avail. I am sure it is
obvious but I am lost. Does anyone have any ideas?
Thanks so much,
Murray
I use nw.js (node + chromium) to build desktop apps for Windows, OSX,
Linux.
I want to use CucumberJS to run my Gherkin feature files within the nw.js
app.
I can run features via the CLI. I can run features via execFile() child
process. But what I want to do is to run the tests in the nw.js node
context directly so I can test my app. Note that I am not interested in
testing the DOM. I want to test the vanilla JS business logic that is
running in this node context. It does not need the DOM or UI.
So, I set up the files as per the instructions here:
https://github.com/cucumber/cucumber-js/blob/master/docs/nodejs_example.md
Then I created a tests.js script that runs when the app starts as below.
What I cant work out is how to invoke CucumberJS directly. What method do I
call and with what params?
console.log('Start tests');
/*
Re:
https://github.com/cucumber/cucumber-js/blob/master/docs/nodejs_example.md
I have created the following files as per that nodejs_example.md page:
features/simple_math.feature
features/support/world.js
features/support/steps.js
That page then says:
Run ./node_modules/.bin/cucumber-js
*/
// I can do this and it runs in the child process. All good.
execFile(
'node_modules/.bin/cucumber-js',
['simple_math', '-f', 'json:' + toJsonFile],
function (error, stdout, stderr) {
// Run the next action.
// ie process the generated json file
}
);
// But I want to run it in THIS node process so I can test the simple_math
feature.
// Of course, in my real app I want to test its JS classes and methods etc,
not just a simple feature.
// So, the World needs to be the JS in this node context.
const cucumber = require('cucumber');
// What I am looking for is the equivalent of this pseudo code.
cucumber.run(
['simple_math', '-f', 'json:' + toJsonFile],
function (error) {
if (!error) {
// Run the next action.
// ie process the generated json file
}
}
);
I have spent hours trying to work this out to no avail. I am sure it is
obvious but I am lost. Does anyone have any ideas?
Thanks so much,
Murray
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.