/qa-async-jobs:sidekiq-testsfrom qa-async-jobs
Guides testing Ruby Sidekiq workers with fake!, inline!, and disable! modes, RSpec/Minitest helpers, job clearing, and assertions on enqueued jobs, arguments, scheduling, retries, and unique jobs.
Ships in qa-async-jobs. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Sidekiq is the de facto Ruby background-job framework on Redis. The testing model per github.com/sidekiq/sidekiq/wiki/Testing:
Three test modes:
| Mode | Behavior |
|---|---|
Sidekiq::Testing.fake! | "pushes all jobs into a jobs array" (default in test env) |
Sidekiq::Testing.inline! | "run jobs inline" (executes immediately, synchronously) |
Sidekiq::Testing.disable! | "Enqueue jobs to Redis as normal" |
Choose fake! for unit tests (assert enqueueing without execution), inline! for integration tests (test the worker itself end-to-end), disable! for tests that need real Redis (e.g., scheduled-job queries against the Sidekiq API).
app/workers/*.rb (or app/jobs/*.rb) with Sidekiq
classes.In spec_helper.rb (RSpec) or test_helper.rb (Minitest):
require 'sidekiq/testing'
Sidekiq::Testing.fake! # default for unit tests
Switch per-test when needed:
it "actually runs the job" do
Sidekiq::Testing.inline! do
create(:order) # triggers OrderConfirmationWorker.perform_async
expect(...).to ...
end
end
Per sk-test, the Minitest helper:
module SidekiqMinitestSupport
def after_teardown
Sidekiq::Worker.clear_all
super
end
end
For RSpec, equivalent:
RSpec.configure do |config|
config.before(:each) { Sidekiq::Worker.clear_all }
end
Without this, jobs accumulate across tests - order-dependent test failures result.
Per sk-test (verbatim RSpec example):
expect {
HardWorker.perform_async(1, 2)
}.to change(HardWorker.jobs, :size).by(1)
Plus assertion on the basic count: assert_equal 0, HardWorker.jobs.size
followed by enqueueing and verifying the count changes.
Inspect job arguments + scheduled time:
HardWorker.perform_in(1.hour, "user-123")
job = HardWorker.jobs.last
expect(job["args"]).to eq(["user-123"])
expect(job["at"]).to be_within(5.seconds).of(1.hour.from_now.to_f)
Without leaving fake! mode, drain executes accumulated jobs:
HardWorker.perform_async(1, 2)
HardWorker.drain # runs all queued HardWorker jobs synchronously
Useful for integration tests that need fake! globally but selectively run a worker's jobs.
Per sk-test: "Sidekiq's API does not have a testing mode" - meaning scheduled-set queries always hit Redis, not the test
harness. To test scheduled jobs in fake! mode, inspect the job's
at field directly (Step 3). For integration testing of the Sidekiq
scheduler API, use Sidekiq::Testing.disable! + a real Redis
instance (Docker / Testcontainers).
Sidekiq retries failed jobs by default (25 retries, exponential backoff). To test retry logic:
it "retries on transient error" do
Sidekiq::Testing.inline!
expect_any_instance_of(HardWorker).to receive(:perform).and_raise(StandardError, "transient")
expect { HardWorker.perform_async }.to raise_error(StandardError)
# In production, Sidekiq would retry; in inline! mode, the raise propagates
end
For more realistic retry testing, switch to disable! + use the
Sidekiq API (Sidekiq::RetrySet.new.size) to count retried jobs in
Redis.
If using sidekiq-unique-jobs gem, unique-lock state lives in Redis;
test in disable! mode against a real Redis instance. fake! mode
does NOT enforce uniqueness (jobs all accumulate in the array
regardless of unique config).
- run: bundle install
- run: bundle exec rspec
# ... or for Minitest:
- run: bundle exec rake test
Sidekiq tests run in the standard Ruby test runner. For tests that need real Redis, use a service container:
services:
redis:
image: redis:7
ports: [6379:6379]
| Anti-pattern | Why it fails | Fix |
|---|---|---|
Test code uses inline! everywhere | Slows tests; couples test to worker internals | fake! for enqueue tests; inline! only for integration |
No Sidekiq::Worker.clear_all between tests | Jobs leak across tests; flaky | Add after_teardown / before(:each) hook (Step 2) |
Test scheduled-set via Sidekiq::ScheduledSet.new.size in fake! mode | API hits Redis, not the fake jobs array; returns 0 unexpectedly | Inspect Worker.jobs.last["at"] instead (Step 3) |
| Test unique-jobs in fake! mode | Uniqueness lock isn't enforced; tests pass-by-accident | Use disable! + real Redis (Step 7) |
ScheduledSet, RetrySet, DeadSet) bypass
the testing mode and always hit Redis (per sk-test).inline! mode runs jobs synchronously in the calling thread -
hides concurrency bugs that production exhibits.celery-tests,
bullmq-tests,
sqs-tests,
rabbitmq-tests - sister toolsidempotency-test-author,
cron-job-test-author -
build-an-X authors for cross-tool patternsWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
sidekiq-testing, background-jobs, rspec, minitest, ruby-testing
npx claudepluginhub testland/qa --plugin qa-async-jobs8 skills in this plugin
/bullmq-testsUse whenever a Node.js or TypeScript service uses BullMQ and its queues or workers need tests: producers, worker processors, retries, backoff and repeat jobs, FlowProducer parent-child jobs and QueueEvents, against real Redis (Docker, Testcontainers) or ioredis-mock./celery-testsUse whenever Python Celery tasks need unit or integration tests: pytest-celery celery_app and worker fixtures, apply() for synchronous calls, why task_always_eager misleads, and mocking task.retry to test retry behavior, for function and class-based tasks./cron-job-test-authorUse when cron jobs, Kubernetes CronJobs, BullMQ repeat jobs, Sidekiq schedules or any time-based job need tests: cron expression validation, DST and leap-day edge cases, catch-up after downtime, overlapping-run locks with stale-lock recovery, and time zones.2 plugins ship this exact skill · first indexed Nov 12, 2026
Other plugins' skills for the same job