Fork me on GitHub
#lumo
<
2017-10-24
>
johnjelinek01:10:55

going back to my gherkin scenario -- if I transpile my cljs, it has deps on goog, and cucumber won't know how to read the files -- is there a way to have lumo simply transpile the cljs to es6 that could run in node?

richiardiandrea02:10:52

@johnjelinek do you have a sharable project? Maybe I can have a look at it tomorrow, I am kind of worried that it is so hard to achieve that 😄

johnjelinek02:10:50

I can come up with a gist, but you can give it a shot by translating these little javascript files into cljs: https://github.com/cucumber/cucumber-js/blob/master/docs/nodejs_example.md

johnjelinek02:10:34

if I build my step_definitions from cljs to js, it ends up looking like this: https://clojurians.slack.com/archives/C03S1L9DN/p1508810459000036

johnjelinek02:10:27

and when I run cucumber via the CLI or via node like this:

import Cli from 'cucumber/lib/cli';

const cli = new Cli.default({
  argv: process.argv,
  cwd: '',
  stdout: process.stdout
})

cli.run();
it complains that it doesn't know what goog is

johnjelinek02:10:59

because the entrypoint is determined by cucumber, so there's not going to be a main.js kind of entrypoint

richiardiandrea02:10:33

Uhm got it, sorry for keeping asking I will try to find some time to actually try this out

johnjelinek19:10:43

FYI when you get around to trying this out, I'm currently trying to run cucumber like this:

./node_modules/.bin/cucumber-js ../features -r out/main.js
where ../features includes my features files and my cljs step definitions

johnjelinek19:10:22

I'm not sure if this is right, but here's what an example step definitions looks like:

(ns step-definitions.steps)

(require 'chromedriver)
(def seleniumWebdriver (js/require "selenium-webdriver"))
(def defineSupportCode (.-defineSupportCode (js/require "cucumber")))

(defn custom-world []
  (this-as this
    (let [builder (new (.-Builder seleniumWebdriver))
          forBrowser (.forBrowser builder "chrome")]
      (set! (.-driver this) (.build forBrowser)))))

(defineSupportCode
  (fn [context]
    (let [set-world-constructor (.-setWorldConstructor context)
          Given (.-Given context)
          When (.-When context)
          Then (.-Then context)
          After (.-After context)]
      (set-world-constructor custom-world)
      (After (this-as this (.quit (.-driver this))))
      (Given "I am on the Cucumber.js GitHub repository" #(println "test"))
      (When "I click on {string}" #(% (println %)))
      (Then "I should see {string}" #(% (println %))))))

johnjelinek19:10:53

that generates some js that looks like this:

// Compiled by ClojureScript 1.9.946 {:target :nodejs}
goog.provide('step_definitions.steps');
goog.require('cljs.core');
step_definitions.steps.node$module$chromedriver = require('chromedriver');
step_definitions.steps.seleniumWebdriver = require("selenium-webdriver");
step_definitions.steps.defineSupportCode = require("cucumber").defineSupportCode;
step_definitions.steps.custom_world = (function step_definitions$steps$custom_world(){
var this$ = this;
var builder = (new step_definitions.steps.seleniumWebdriver.Builder());
var forBrowser = builder.forBrowser("chrome");
return this$.driver = forBrowser.build();
});
step_definitions.steps.defineSupportCode.call(null,(function (context){
var set_world_constructor = context.setWorldConstructor;
var Given = context.Given;
var When = context.When;
var Then = context.Then;
var After = context.After;
set_world_constructor.call(null,step_definitions.steps.custom_world);

After.call(null,(function (){var this$ = this;
return this$.driver.quit();
})());

Given.call(null,"I am on the Cucumber.js GitHub repository",((function (set_world_constructor,Given,When,Then,After){
return (function (){
return cljs.core.println.call(null,"test");
});})(set_world_constructor,Given,When,Then,After))
);

When.call(null,"I click on {string}",((function (set_world_constructor,Given,When,Then,After){
return (function (p1__1_SHARP_){
return p1__1_SHARP_.call(null,cljs.core.println.call(null,p1__1_SHARP_));
});})(set_world_constructor,Given,When,Then,After))
);

return Then.call(null,"I should see {string}",((function (set_world_constructor,Given,When,Then,After){
return (function (p1__2_SHARP_){
return p1__2_SHARP_.call(null,cljs.core.println.call(null,p1__2_SHARP_));
});})(set_world_constructor,Given,When,Then,After))
);
}));

richiardiandrea01:10:40

Ok thanks did not have time today but it is queued

johnjelinek23:10:48

any luck with this?

richiardiandrea00:10:02

sorry I have not had time for this yet...it still is in my queue though