shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
Franklin 2021-05-16T06:14:09.317800Z

hello, I'm trying to run tests with karma and I get this error:

user:shadow-quagga$ yarn karma start --single-run
yarn run v1.21.1
$ /home/user/work/node_modules/.bin/karma start --single-run
16 05 2021 09:13:28.366:INFO [karma-server]: Karma v6.3.2 server started at <http://localhost:9876/>
16 05 2021 09:13:28.367:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
16 05 2021 09:13:28.371:INFO [launcher]: Starting browser ChromeHeadless
16 05 2021 09:13:28.623:INFO [Chrome Headless 90.0.4430.212 (Linux x86_64)]: Connected on socket BOp0uUsEZlSbo7HdAAAB with id 30514711
Chrome Headless 90.0.4430.212 (Linux x86_64) ERROR
  ReferenceError: test is not defined
      at eval (eval at &lt;anonymous&gt; (/home/user/work/zebra/shadow-quagga/node_modules/karma-cljs-test/adapter.js:6:7), &lt;anonymous&gt;:1:15)
      at ContextKarma.start (/home/user/work/zebra/shadow-quagga/node_modules/karma-cljs-test/adapter.js:6:7)
      at ContextKarma.loaded (<http://localhost:9876/context.js:180:14>)
      at <http://localhost:9876/context.html:38:22>

thheller 2021-05-16T07:29:37.319300Z

yeah this in JS quagga.runner-test.run means quagga.runner MINUS test.run

👍 1
Franklin 2021-05-16T06:15:04.317900Z

not sure what I'm missing... I have a test build that looks like this

:ci {:target :karma
       :output-to "out/ci.js"
       :ns-regexp "-test$"}

Franklin 2021-05-16T06:15:39.318100Z

my karma.conf.js looks like this

// See <http://karma-runner.github.io/1.0/config/configuration-file.html>
module.exports = function(config) {
    config.set({
        frameworks: ['cljs-test'],
        plugins: ['karma-cljs-test', 'karma-chrome-launcher', 'karma-junit-reporter'],

        basePath: 'out',

        // If you need to include custom JavaScript files, put them here.
        files: [
            // We serve all the JS files via Karma's webserver so that you can
            // use :optimizations :none. Only test_suite.js is included because
            // CLJS does its own module loading.
            'ci.js'
        ],
        colors: true,
        logLevel: config.LOG_INFO,
        client: {
            args: ['quagga.runner-test.run'],
            singleRun: true
        },

        // If you don't like the progress reporter, you could try 'dots'
        reporters: ['progress', 'junit'],

        // If you want to use other browsers, you need to install the launchers
        // for them! E.g. npm install --save-dev karma-firefofx-launcher
        browsers: ['ChromeHeadless'],

        reportSlowerThan: 500, // ms

        // We disable autoWatch, because it executes tests while the code is
        // still comiling. We use :notify-command to trigger them instead.
        autoWatch: false,

        // Configuration for JUnit output. We care only about the output directory.
        // This directory is relative to basePath, so the XML files will be 
        // in `target/out/reports`.
        // &lt;<https://github.com/karma-runner/karma-junit-reporter#configuration>&gt;
        junitReporter: {
            outputDir: 'reports'
        }
    });
}

Franklin 2021-05-16T06:16:41.318300Z

in the quagga.runner-test namespace I have a run function that looks like this

(defn ^:export run [karma]
  (karma/run-tests
   karma
   'quagga.events-test))

Franklin 2021-05-16T06:17:39.318500Z

an in the quagga.events-test namespace

(ns quagga.events-test
  (:require [cljs.test :refer-macros [deftest is testing run-tests]]))

(deftest first-test
  (testing "hello world test"
    (is (= 1 1))))

Franklin 2021-05-16T06:22:13.318800Z

actually, I found my issue

Franklin 2021-05-16T06:22:42.319Z

seems a _ was expected where I placed a -

Margo 2021-05-16T08:24:58.320400Z

Hello, people! Trying to figure out how to configure cljfmt with shadow-cljs.edn . Any tips?

thheller 2021-05-16T08:43:58.320900Z

you can run it via shadow-cljs run cljfmt.main

🙌 1