Fork me on GitHub
#shadow-cljs
<
2021-05-16
>
Franklin06:05:09

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 
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 <anonymous> (/home/user/work/zebra/shadow-quagga/node_modules/karma-cljs-test/adapter.js:6:7), <anonymous>:1:15)
      at ContextKarma.start (/home/user/work/zebra/shadow-quagga/node_modules/karma-cljs-test/adapter.js:6:7)
      at ContextKarma.loaded ()
      at 

Franklin06:05:04

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$"}

Franklin06:05:39

my karma.conf.js looks like this

// See 
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`.
        // <>
        junitReporter: {
            outputDir: 'reports'
        }
    });
}

Franklin06:05:41

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

Franklin06:05:39

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

Franklin06:05:13

actually, I found my issue

Franklin06:05:42

seems a _ was expected where I placed a -

thheller07:05:37

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

👍 3
Margo08:05:58

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

thheller08:05:58

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

🙌 3