Fork me on GitHub
#nbb
<
2022-05-24
>
gdubs04:05:51

Surprised that these console.log different things?

gdubs04:05:49

I am! 🙂

borkdude06:05:11

I'm not but that can be fixed :) - issue welcome

👍 1
martinklepsch13:05:43

Did anyone explore Cypress + nbb yet? Can that work at all?

viesti14:05:50

I did a trial, forgot about it, found it now and too ashamed to put it out in the open 😄

littleli14:05:11

There are examples for puppeteer and playwright. I believe (I cannot claim) that testing is one of the cases @U04V15CAJ would like to have covered. @U06QSF3BK you should not be ashamed! can you share anything? at least in gist or something?

borkdude14:05:12

testing with cljs.test is covered in the docs. Node.js projects that behave like frameworks should probably be used with a JS wrapper

viesti14:05:10

Buuut, it went like this • nbb is meant to run ontop of node, but the JavaScript that Cypress test is, is run in the browser • So we kinda want sci in the browser • but hey! nbb.loadString() let's try that! • um... how do I carry a string for nbb to load into the browser • wait, I think one can require("file.json") and webpack then bundles the json into the javascript bundle • neat! let's try writing a cypress preprocessor that when seeing a .cljs file, grabs the source, writes it into a source.json file, then spits out a javascript file that does uses nbb to load the code, something like

fs.writeFileSync(stubPath, `const code = require('${codePath}'); console.log(code.code); import {loadString} from \"nbb\"; loadString(code.code)`);
• then I look at that I did and go hmm....

viesti14:05:43

now I go off to have dinner :D

borkdude14:05:37

cypress runs in the browser? for browser testing I'd go with playwright + cljs.test then

littleli14:05:11

hmm, from what I understand they have a Dashboard which instruments tests written as .js "modules". So maybe go with js wrapper makes sense. Although it's a bit awkward 😞

borkdude14:05:25

ff-ing frameworks

borkdude14:05:36

"let's make things easy" :P

viesti14:05:02

random google, but I guess the initial idea was to try do a bit different https://www.toolsqa.com/cypress/what-is-cypress/

viesti14:05:54

the test script is run inside the browser, in an iframe IIRC, somehow it talks to the driver that is a node program, I guess the initial idea was to have a more direct access to stuff inside the browser, but yeah, this kinda puts the "test" in a bit awkward position, since you can only run javascript, which puts you into the "let's make everything as javascript" bundle mangle

viesti14:05:38

contrasting this to stuff that talks to a browser and to a test that executes outside the browser, I guess those things used to be a bit crippled back in the day

viesti14:05:55

now things might have turned into different direction

viesti14:05:00

oh the technology

littleli14:05:20

If I remember correctly, in our company, we had cypress, but later we moved to puppeteer, because it was giving us better results. I think playwright would be our choice these days - because supporting multiple browsers.

martinklepsch21:05:19

I didn’t realize Playwright can deal with multiple browsers, that’s a real game changer for us as Cypress has been pretty limiting in that regard

borkdude19:05:58

etaoin (webdriver) is now also compatible with babashka: https://github.com/clj-commons/etaoin so you could also try that approach

zimablue14:05:34

hey, is there anything in clojurescript/SCI that wraps process initialization through nodejs? like this js lib: https://github.com/sindresorhus/open asking here as it's an intersection of clojurescipt and node, also asked on the main channel

borkdude14:05:27

@zimablue Why not use that library ? nbb is designed so you can easily use npm libs

zimablue14:05:45

yeah I was about to use it and thought I should check if something in clj-x exists as it will be easier to debug /read without context switching

zimablue14:05:55

if none immediately comes to your mind there probably isn't one

emccue18:05:14

Just checking (idk the usefulness) - has anyone written an "express-ring-adapter" or similar?

borkdude20:05:31

@emccue There is this: https://github.com/macchiato-framework/macchiato-core I don't think it runs out of the box with nbb, but we could try to make that work.