본문으로 건너뛰기
cccskills
무료GitHub에 공개

sidekiq-tests

Authors and runs Sidekiq job tests in Ruby - three Sidekiq::Testing modes (`fake!` jobs accumulate in arrays, `inline!` runs jobs immediately, `disable!` enqueues to Redis as normal); RSpec + Minitest helper patterns; clears jobs between tests via `Sidekiq::Worker.clear_all`; assertion patterns on `MyWorker.jobs.size` and `MyWorker.jobs.first[:args]`. Use when the user works with Sidekiq workers and needs unit / integration tests for job enqueueing, scheduling, retry behavior, or unique-job semantics.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

testland/qa스타 13(GitHub 13 + cccskills 0)
연동 도구Redis

실행 점수 미검증

설치 방법 보기

포함된 파일(2)

  • SKILL.md6.2 KB
  • .tessl-plugin/plugin.json635 B

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

sidekiq-tests

Overview

Sidekiq is the de facto Ruby background-job framework on Redis. The testing model per github.com/sidekiq/sidekiq/wiki/Testing:

Three test modes:

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

When to use

  • The repo has app/workers/*.rb (or app/jobs/*.rb) with Sidekiq classes.
  • The user writes tests for job enqueueing logic (controllers / services).
  • Tests need to assert on job count, scheduled time, or arguments.
  • A test verifies retry / dead-set / unique-job behavior.

Step 1 - Configure test mode

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

Step 2 - Clear jobs between tests

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.

Step 3 - Assert enqueueing (fake! mode)

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)

Step 4 - Drain (execute) queued fake! jobs

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.

Step 5 - Test scheduled 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).

Step 6 - Test retry behavior

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.

Step 7 - Test unique-jobs semantics

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

Step 8 - CI integration

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

Anti-patternWhy it failsFix
Test code uses inline! everywhereSlows tests; couples test to worker internalsfake! for enqueue tests; inline! only for integration
No Sidekiq::Worker.clear_all between testsJobs leak across tests; flakyAdd after_teardown / before(:each) hook (Step 2)
Test scheduled-set via Sidekiq::ScheduledSet.new.size in fake! modeAPI hits Redis, not the fake jobs array; returns 0 unexpectedlyInspect Worker.jobs.last["at"] instead (Step 3)
Test unique-jobs in fake! modeUniqueness lock isn't enforced; tests pass-by-accidentUse disable! + real Redis (Step 7)

Limitations

  • Sidekiq's API queries (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.
  • Unique-jobs semantics need real Redis to test (Step 7).
  • Sidekiq Pro / Enterprise features (batches, super-workers) have their own testing patterns not covered here - consult their docs.

References

  • sk-test - testing modes, RSpec + Minitest examples, helper patterns
  • github.com/sidekiq/sidekiq - repository
  • celery-tests, bullmq-tests, sqs-tests, rabbitmq-tests - sister tools
  • idempotency-test-author, cron-job-test-author - build-an-X authors for cross-tool patterns

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Builds a CI gate that fails the build on **new** WCAG / a11y violations introduced by a PR while grandfathering pre-existing violations on a per-rule / per-page baseline. Aggregates verdicts from axe-core / pa11y / Lighthouse a11y / WAVE / IBM Equal Access scans. Use when a project has accumulated a11y debt and a strict "zero violations" gate would block every PR - the ratchet pattern lets the team ship while preventing regressions.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

testland/qa132026년 10월 20일 업데이트

Workflow skill that builds an A/B-test validity checklist from an experiment proposal, walking the canonical design-correctness gates - pre-registered OEC/power/guardrails, randomization unit + SRM check, assignment integrity, telemetry, peeking discipline, novelty/primacy, post-experiment SRM re-check - into a per-experiment checklist + sign-off form. Use when launching, auditing, or governing an experiment. For pitfall mechanics (guardrails, peeking) see experiment-results-interpreter's references; to read an already-valid result use experiment-results-interpreter; for per-SDK harness tests use experiment-sdk-testing - this gates DESIGN, not SDK code.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

testland/qa132026년 10월 20일 업데이트

The single install-flow skill: the reference contract for the PWA install flow (installability gate fields, `beforeinstallprompt` handshake, per-platform paths - Android WebAPK / iOS Share menu / Firefox no-op - and the `display-mode` post-install signal, in references/install-flow-reference.md) plus the build-an-X workflow that emits the Add-to-Home-Screen suite. Walks the four-stage timeline, emitting one test per gate cell per [web.dev/articles/install-criteria][install-criteria], the deferred-prompt → `prompt()` → `userChoice` chain per [web.dev/articles/customize-install][customize-install], the iOS Safari manual-metadata branch (`apple-touch-icon`) per [web.dev/learn/pwa/installation][learn-pwa], and the post-install `(display-mode: standalone)` MQ assertion. Output: a Playwright spec with per-stage cells plus a coverage matrix. Use when a PWA's manifest, icons, or install handler change, when install conversion drops at an unknown stage, or when triaging a flaky install assertion.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

testland/qa132026년 10월 20일 업데이트

Build-an-X workflow that uses an LLM to map existing tests to spec sections - given a spec doc + the test suite, the LLM identifies which tests cover which sections, surfaces uncovered sections (gap), and recommends specific tests to add. Output is a coverage matrix per spec ID. Scope is mapping tests that already exist and naming the gaps, not authoring tests for new acceptance criteria. Use when a spec doc and a test suite both exist but nobody can say which requirements are actually covered - before a release sign-off, an audit, or a decision about where to spend the next round of test effort.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

testland/qa132026년 10월 20일 업데이트

Generates tests from natural-language specs (acceptance criteria, user stories, requirements) using an LLM, with confidence scoring per test case (LLM self-assessment plus heuristics: assertion quality, naming, completeness), batching uncertain cases for human review, and integration with the team's existing test framework. Use when the user asks to generate unit tests from acceptance criteria, convert user stories to test cases, automate test creation from requirements, or augment a spec-driven test suite with AI-generated stubs that are then curated before merge.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

testland/qa132026년 10월 20일 업데이트

Configures Allure Report (test-runner adapter install, `allure-results` directory wiring, `categories.json` for failure classification, `history-trend.json` retention via the copy-history-between-runs pattern), runs the Allure CLI to convert `allure-results` to a static HTML site, and uploads the report as a CI artifact. Use when the team needs richer test reporting than JUnit XML - step-level attachments, per-test history, retry tracking, and severity / epic / feature labeling across framework-agnostic adapters (pytest, Jest, JUnit, TestNG, NUnit, Mocha). As a rich static HTML report generator, it is the open-source alternative to the sunset ExtentReports (JVM/.NET per-test HTML narrative); for hosted cross-run flakiness analytics rather than a static per-run report use currents-integration.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

testland/qa132026년 10월 20일 업데이트

testland의 스킬 모두 보기

이 스킬의 문제 신고