ruby-on-railsminitestruby-on-rails-7ruby-on-rails-7.2

ArgumentError: assert_no_enqueued_jobs requires the Active Job test adapter, you're using ActiveJob::QueueAdapters::SidekiqAdapter


We've been looking to upgrade to Rails 7.2.0 and we're getting a new error in MiniTest (v 5.24.1).

ArgumentError: assert_no_enqueued_jobs requires the Active Job test adapter, you're using ActiveJob::QueueAdapters::SidekiqAdapter.

I can't see any notes in the Rails Changelog or open issues

Any suggestions on how to fix?


Solution

  • You have to set your adapter for test environment:

    # config/environment/test.rb
    
    config.active_job.queue_adapter = :test
    

    All tests now respect the active_job.queue_adapter config.

    Previously if you had set config.active_job.queue_adapter in your config/application.rb or config/environments/test.rb file, the adapter you selected was previously not used consistently across all tests. In some tests your adapter would be used, but other tests would use the TestAdapter.

    In Rails 7.2, all tests will respect the queue_adapter config if provided. If no config is provided, the TestAdapter will continue to be used.

    See #48585 for more details.

    https://github.com/rails/rails/blob/v7.2.0/activejob/CHANGELOG.md#rails-720-august-09-2024