Discussion:
[Cucumber] [JS] Attempting to get CucumberJS running in nw.js node context
(too old to reply)
Murray Hopkins
2018-07-31 14:09:06 UTC
Permalink
Raw Message
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
--
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.
Murray Hopkins
2018-07-31 21:00:57 UTC
Permalink
Raw Message
Something like this in Jasmine:

var Jasmine = require('jasmine');var jasmine = new Jasmine();
jasmine.loadConfigFile('spec/support/jasmine.json');jasmine.configureDefaultReporter({
showColors: false});jasmine.execute();
--
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.
Steve Tooke
2018-08-01 09:24:52 UTC
Permalink
Raw Message
Hi Murray,

I don’t have a direct answer to your question, but it sounds like you might
get some inspiration from cucumber-electron
https://github.com/cucumber/cucumber-electron.

Cheers
Steve
Post by Murray Hopkins
var Jasmine = require('jasmine');var jasmine = new Jasmine();
jasmine.loadConfigFile('spec/support/jasmine.json');jasmine.configureDefaultReporter({
showColors: false});jasmine.execute();
--
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
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.
Murray Hopkins
2018-08-01 12:53:39 UTC
Permalink
Raw Message
Thanks Steve. I will certainly have a look. :-)
Post by Steve Tooke
Hi Murray,
I don’t have a direct answer to your question, but it sounds like you
might get some inspiration from cucumber-electron
https://github.com/cucumber/cucumber-electron.
Cheers
Steve
Post by Murray Hopkins
var Jasmine = require('jasmine');var jasmine = new Jasmine();
jasmine.loadConfigFile('spec/support/jasmine.json');jasmine.configureDefaultReporter({
showColors: false});jasmine.execute();
--
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
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 a topic in the
Google Groups "Cukes" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/cukes/79kB7WAc2Gk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
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.
Loading...