Token导航 LogoToken导航TokenDH.com
开发操作浏览器github未标认证来源可访问许可证需确认审计通过

testing-clojure-cljs测试 Clojure cljs

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

222

周安装

9

GitHub Stars

2

下载量

70
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:testing-clojure-cljs(测试 Clojure cljs)
来源仓库:https://github.com/riatzukiza/devel
仓库路径:skills/testing-clojure-cljs
安装命令:
npx skills add https://github.com/riatzukiza/devel --skill testing-clojure-cljs
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/riatzukiza/devel --skill testing-clojure-cljs

简介

用于 Clojure/ClojureScript 项目的单元与集成测试。

  • 适合运行本地测试套件并生成覆盖率报告。
  • 支持 REPL 驱动的开发模式与热重载调试。
  • 需确保 Leiningen 或 shadow-cljs 等构建工具已就绪。
  • testing-clojure-cljs 属于开发类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Skill: Testing Clojure ClojureScript

Goal

Set up and write tests for Clojure and ClojureScript projects using cljs.test, cljs-init-tests, and shadow-cljs workflow.

Use This Skill When

  • Testing Clojure or ClojureScript code
  • Setting up test infrastructure for CLJS projects
  • Using shadow-cljs for compilation
  • The user asks to "add Clojure tests" or "set up cljs.test"

Do Not Use This Skill When

  • Testing TypeScript/JavaScript code (use testing-typescript-vitest)
  • Project uses a different Clojure test framework (midje, test.check)

ClojureScript Test Setup

shadow-cljs Configuration

;; shadow-cljs.edn
{:source-paths ["src" "test"]
 :dependencies [[cider/cider-nrepl "0.28.5"]
                [cider/orchard "0.11.0"]]

 :builds {:test {:target :browser-test
                 :output-to "target/test/test.js"
                 :tests {:matches #".*-test$"}
                 :devtools {:http-port 8080
                            :http-resource-root "target/test"}}

          :node-test {:target :node-test
                      :output-to "target/test/node-test.js"
                      :tests {:matches #".*-test$"}}}}

package.json Scripts

{
  "scripts": {
    "test:cljs": "shadow-cljs compile node-test && node target/test/node-test.js",
    "test:browser": "shadow-cljs compile test && npx http-server target/test -p 8080",
    "test:watch": "shadow-cljs watch test"
  }
}

Basic cljs.test Syntax

(ns my-project.core-test
  (:require [cljs.test :refer [deftest is testing are]]
            [my-project.core :as core]))

(deftest add-test
  (testing "addition"
    (is (= (core/add 2 3) 5))
    (is (= (core/add -1 1) 0))
    (is (= (core/add 0 0) 0))))

(deftest subtract-test
  (testing "subtraction"
    (is (= (core/subtract 5 3) 2))
    (is (= (core/subtract 3 5) -2))))

(deftest multiply-test
  (testing "multiplication"
    (are [x y] (= (core/multiply x y) (* x y))
         2 3
         -1 5
         0 10)))

Test Assertions

(deftest assertion-examples
  (testing "basic assertions"
    (is true)
    (is (= 1 1))
    (is (not false)))

  (testing "collection assertions"
    (is (empty? []))
    (is (seq [1 2 3]))
    (is (contains? {:a 1} :a))
    (is (contains? [1 2 3] 0)))

  (testing "exception handling"
    (is (thrown? js/Error
           (throw (js/Error. "test")))))

  (testing "approx assertions for floats"
    (is (== 0.3 (+ 0.1 0.2)))))

Testing Async Code

(ns my-project.async-test
  (:require [cljs.test :refer [deftest is testing async]]
            [my-project.async :as async]))

(deftest async-test
  (async done
    (async/timeout 100
      (is true))
    (done)))

(deftest promise-test
  (async done
    (-> (async/load-data)
        (.then (fn [data]
                 (is (= (:status data) 200))
                 (done)))
        (.catch (fn [err]
                  (is false "Should not error")
                  (done))))))

cljs-init-tests Macro

The cljs-init-tests provides convenient initialization for tests:

(ns my-project.init-test
  (:require [cljs-init-tests.core :refer [init-tests deftest-test]]
            [my-project.math :as math]
            [cljs.test :refer [deftest is testing]]))

;; Initialize test infrastructure
(init-tests)

;; Test definitions work normally
(deftest math-tests
  (testing "basic math operations"
    (is (= (math/add 2 3) 5))
    (is (= (math/subtract 5 3) 2))))

Setup and Fixtures

(ns my-project.fixtures-test
  (:require [cljs.test :refer [deftest use-fixtures testing]]
            [my-project.db :as db]))

;; Define fixtures
(defn setup-db [f]
  (db/reset!)
  (f)
  (db/cleanup!))

(defn with-logging [f]
  (println "Starting test")
  (f)
  (println "Finished test"))

;; Use fixtures
(use-fixtures :once setup-db)
(use-fixtures :each with-logging)

(deftest database-test
  (testing "database operations"
    (is (some? (db/connect)))
    (is (db/insert {:name "test"}))))

Testing CLJS-Specific Features

(ns my-project.cljs-specific-test
  (:require [cljs.test :refer [deftest is testing]]
            [cljs.core :as c]))

(deftest atom-test
  (let [counter (atom 0)]
    (swap! counter inc)
    (is (= @counter 1))
    (swap! counter inc)
    (is (= @counter 2))))

(deftest reagent-test
  (let [component (fn []
                    [:div "Hello"])]
    (is (fn? component))))

(deftest protocol-test
  (let [record (->Record. :field)]
    (is (= (:field record) :field))))

Shadow-cljs Test Compilation

Test Build Output

# Compile for Node.js
shadow-cljs compile node-test

# Compile for browser
shadow-cljs compile test

# Watch and test
shadow-cljs watch test

CI/CD Integration

#!/bin/bash
# run-cljs-tests.sh

set -e

# Install dependencies
yarn install

# Compile tests
shadow-cljs compile node-test

# Run tests
node target/test/node-test.js

# Check exit code
if [ $? -eq 0 ]; then
  echo "Tests passed!"
  exit 0
else
  echo "Tests failed!"
  exit 1
fi

Organization

src/
└── my_project/
    ├── core.cljs
    └── core_test.cljs  # Test in same namespace

test/
└── my_project/
    ├── integration_test.cljs
    └── e2e_test.cljs

Best Practices

1. Test Naming

;; GOOD - descriptive test names
(deftest add-two-positive-numbers-returns-sum)
(deftest handle-empty-input-gracefully)

;; BAD - vague names
(deftest test-add)
(deftest test-stuff)

2. Test Organization

(deftest arithmetic-tests
  (testing "addition"
    (is (= (+ 2 3) 5))
    (is (= (+ 0 0) 0)))

  (testing "subtraction"
    (is (= (- 5 3) 2))))

3. Property-Based Testing

;; With test.check
(deftest sort-is-idempotent
  (let [gen (gen/vector gen/int)]
    (is (forall [v gen]
           (= (sort v) (sort (sort v)))))))

Running Tests

CommandPurpose
shadow-cljs compile testCompile for browser
shadow-cljs compile node-testCompile for Node.js
shadow-cljs watch testWatch and test
shadow-cljs testRun tests via CLI

Output

  • shadow-cljs.edn configuration
  • Test namespace setup with cljs.test
  • Example test files for CLJS
  • Fixtures and setup patterns
  • CI/CD test script

References

Suggested Next Skills

Check the Skill Graph for the full workflow.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

37.61%
按下载量换算26

Claude

30.93%
按下载量换算22

Cursor

20%
按下载量换算14

Gemini CLI

8.44%
按下载量换算6

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills