lambdaisland / kaocha-cljs2 Goto Github PK
View Code? Open in Web Editor NEWRun ClojureScript tests from Kaocha (major rewrite)
License: Mozilla Public License 2.0
Run ClojureScript tests from Kaocha (major rewrite)
License: Mozilla Public License 2.0
The more tests I am adding the more often they are failing because of timeouts.
I have started to write client tests using @testing-library and everything was quite okay in the beginning but after some time I have started to receive Timeout errors like the below one.
Kaocha: Syntax error (ExceptionInfo) compiling at (/private/var/folders/86/2tqdp6j561z4z540d98w4ydw0000gp/T/form-init12547904487930344475.clj:1:126).
Timeout
I have increased the wait time for @testing-library to 14000 and this helped to have them stable for some time.
It is worth adding that the lowest resources were on machines the more often I got those errors. Because of that I have stopped using kaocha-cljs2
on CI and came back to karma there.
My Mac becomes very loud when I run tests and on the Activity Monitor, I can see how jvm and Chromium are taking most of the resources during the run (more than 100%)
The tests are not failing when Chui UI is used and I can easily run all of them there, but when I am trying to run them from the command line using kaocha :type :kaocha.type/cljs2
and headless browser they are failing on one or another async test.
The one thing which helps me right now is splitting all my tests in chunks using :skip-meta
and :focus-meta
and run them one by one using :kaocha.type/cljs2
Could it be that :kaocha.type/cljs2
doesn't clean up properly between tests and keeps everything until the end of the run in either browser or jvm?
Lines 4 to 5 in 2a3489d
Those lead to outdated glogi transient dependencies which are not compatible with latest ClojureScript/Closure Library versions.
kaocha.report/documentation
reporter doesn't show testing
text in reports for cljs.test
package. Works fine when clj.test
package is used
For the example below
(ns login.core-tests
(:require [cljs.test :refer [deftest testing is]]))
(deftest login-logo-test
(testing ("logo should be shown")))
login.core-tests
login-logo-test
logo should be shown
login.core-tests
login.core-tests/login-logo-test
For CI or Git push hook cases the Chui UI is not needed at all, is it possible to run tests without it?
When tests are run using :kaocha.type/cljs2
the coverage is shown only for ".cljc" files but not for the ".cljs".
Is it a known issue?
hello. in the config you can specify :kaocha.cljs2/timeout xxx
and that gets passed through to the funnel client listen!
function https://github.com/lambdaisland/kaocha-cljs2/blob/main/src/kaocha/cljs2/funnel_client.clj#L53 for the 'load' of the tests from the initial config. when it comes to the next stage of loading - getting tests from the clients, the timeout is not passed on - it is nil.
Note. this description ^^^ might not be quite right. the process of loading and running in kaocha is not completely clear to me. but the first time listen! is called the timeout is there, and the next time it is nil - that I can say for sure
so... in an attempt to get my suites passing I have changed this line in my branch https://github.com/henryw374/kaocha-cljs2/blob/main/src/kaocha/type/cljs2.clj#L99 - to call add-timeouts
before the load. this seems to work...
Cljdoc attempts to require the kaocha.cljs2.autorequire
namespace. Unfortunately, this fails when required from the ClojureScript process, as this namespace must be run from a testable.
(assert (= :kaocha.type/cljs2 (:kaocha.testable/type testable/*current-testable*)))
hello. I found a weird bug that took quite some time to track down...
calling (run)
function in this ns does not filter tests as expected. If I move the fn into a namespace with some other name, things work
(ns cljs)
(defn run []
(kaocha.repl/run
{:kaocha/tests
[{:kaocha.testable/id :browser-tests
:kaocha.testable/type :kaocha.type/cljs2}]
:kaocha.filter/focus [:skip-me ]}))
If no chui-remote clients are connected, Kaocha will wait forever. You can configure a timeout, but it's not enabled by default.
This is technically correct behavior and thus, arguably, not a true hang (which implies a deadlock or other invalid state), but it isn't very friendly to people setting it up for the first time.
Hi,
I am using a different file organization than the default one. Tests files are located in ./src/test
without special filenames. Just like for regular Kaocha, in Kaocha-CLJS I was using this sort of configuration:
{:id :node
:type :kaocha.type/cljs
:kaocha/ns-patterns [".+"]
:kaocha/source-paths ["src/main"]
:kaocha/test-paths ["src/test"])
However, with Kaocha-CLJS2, I get:
WARNING: No tests were found, make sure :test-paths and :ns-patterns are configured correctly in tests.edn.
I have no idea if I am doing something wrong or if, for some reason, those options are not supported. I have a bit of a trouble migrating from version 1 for node + Chui for browser to version 2 for everything.
I started a kaocha watch in shadow-cljs clj-repl, so that everytime the cljs code changes the test could be auto-run.
yarn shadow-cljs clj-repl
> (kaocha.watch/run (kaocha.repl/config))
However kaocha immediately runs the tests after a file change - before shadow-cljs finishes hot reloading. So it's the old code that gets tested, not the most recent version.
So I guess we need a way to let kaocha/chui-remote to "wait for a shadow-cljs reload event and only then run the tests".
https://app.circleci.com/pipelines/github/lambdaisland/kaocha-cljs2 seems to not be running any more for some reason. e.g. latest master hasn't been run.
this is a standard feature in regular clojure jvm tests. as a workaround I made this hook: https://gist.github.com/henryw374/6ba4359f540412baae4510d790fcf273
It would be cool to have this as a standard feature. thanks
kaocha.cljs2.shadow-runner sets logging level to :all by default.
when the call is made to
lambdaisland.chui.test-data/capture-test-data! the entirety of test info is printed to the console. This causes problems when there are a large number of tests - e.g. message is too large for channel when attached to chrome debugger.
I don't see a way for clients to set the logging levels, other than writing a new runner ns similar to the shadow-runner.
Kaocha has upgraded, kaocha-cljs2 needs to upgrade as well not, since it defines custom printers.
See change here: lambdaisland/kaocha-cljs@a234209#diff-14e0e5c88284d3d958324f7f3888e212cbfcfc252cf1906af1922e73a0682ffe
The #configure-your-test-suite section of Readme states
See the examples directory and this repository for specific examples.
The specified link is a 404.
shadow-runner
doesn't work in minimal setupTests run without problems.
shadow-cljs - config: /Users/main/Code/clojure/kaocha-cljs2/shadow-cljs.edn
shadow-cljs - starting via "clojure"
[:test] Compiling ...
========= Running Tests =======================
SHADOW import error /Users/main/Code/clojure/kaocha-cljs2/.shadow-cljs/builds/test/dev/out/cljs-runtime/lambdaisland.chui.remote.js
/Users/main/Code/clojure/kaocha-cljs2/.shadow-cljs/builds/test/dev/out/cljs-runtime/lambdaisland/glogi.cljs:87
(some-> (logger name) (.setLevel (level lvl))))
^
TypeError: G__19978.setLevel is not a function
at Object.lambdaisland$glogi$set_level [as set_level] (/Users/main/Code/clojure/kaocha-cljs2/.shadow-cljs/builds/test/dev/out/cljs-runtime/lambdaisland/glogi.cljs:87:25)
at Object.lambdaisland$glogi$set_levels [as set_levels] (/Users/main/Code/clojure/kaocha-cljs2/.shadow-cljs/builds/test/dev/out/cljs-runtime/lambdaisland/glogi.cljs:92:3)
at /Users/main/Code/clojure/kaocha-cljs2/.shadow-cljs/builds/test/dev/out/cljs-runtime/lambdaisland/chui/remote.cljs:23:1
at global.SHADOW_IMPORT (/Users/main/Code/clojure/kaocha-cljs2/out/node-tests.js:64:44)
at /Users/main/Code/clojure/kaocha-cljs2/out/node-tests.js:1681:1
at Object.<anonymous> (/Users/main/Code/clojure/kaocha-cljs2/out/node-tests.js:1688:3)
at Module._compile (node:internal/modules/cjs/loader:1109:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
at Module.load (node:internal/modules/cjs/loader:989:32)
at Function.Module._load (node:internal/modules/cjs/loader:829:14)
===============================================
[:test] Build completed. (164 files, 2 compiled, 0 warnings, 3.05s)
git clone https://github.com/wildwestrom/kaocha2-shadow-test.git && cd kaocha2-shadow-test
yarn install
:test
buildshadow-cljs compile test
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.