lumo

:lumo: Standalone ClojureScript environment. Currently at version 1.9.0
johnjelinek 2017-10-24T01:37:55.000041Z

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?

richiardiandrea 2017-10-24T02:54:52.000183Z

@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 😄

johnjelinek 2017-10-24T02:55:50.000104Z

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

johnjelinek 2017-10-24T02:56:34.000199Z

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

johnjelinek 2017-10-24T02:57:27.000036Z

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

johnjelinek 2017-10-24T02:57:59.000083Z

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

richiardiandrea 2017-10-24T02:59:33.000157Z

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

👍 1
johnjelinek 2017-10-24T19:02:43.000251Z

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

johnjelinek 2017-10-24T19:03:22.000472Z

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 %))))))

johnjelinek 2017-10-24T19:04:53.000421Z

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))
);
}));

richiardiandrea 2017-10-25T01:19:40.000105Z

Ok thanks did not have time today but it is queued

👍 1
johnjelinek 2017-10-30T23:36:48.000240Z

any luck with this?

richiardiandrea 2017-10-31T00:39:02.000046Z

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

👍 1