No commit activity in last 3 years
No release in over 3 years
Allows you to add jest to your Guard toolchain, so that jest is run.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 10.0
~> 3.0

Runtime

~> 2.1
 Project Readme

Guard::JestRunner

Guard::JestRunner allows you to automatically run jest when you change a Javascript/ES6 file.

Unlike guard-jest, this guard runs just as directed by your Guardfile, which allows you to use it in a group and use a Red-Green-Refactor process.

Installation

Add this line to your application's Gemfile:

gem 'guard-jest_runner'

And then execute:

$ bundle

Or install it yourself as:

$ gem install guard-jest_runner

Usage

Please read Guard usage doc.

Guardfile

For a typical Rails app with webpack:

guard :jest do
  watch(%r{app/javascript/(.+)\.js$}) { |m| "spec/javascript/#{m[1]}.test.js" }
  watch(%r{spec/javascript/.+\.js$})
end

(Recommended) pair up with guard-eslint to get a Red-Green-Refactor process:

group :red_green_refactor_js, halt_on_fail: true do
  guard :jest_runner do
    watch(%r{app/javascript/(.+)\.js$}) { |m| "spec/javascript/#{m[1]}.test.js" }
    watch(%r{spec/javascript/.+\.js$})
  end

  guard :eslint, formatter: 'codeframe' do
    watch(%r{app/javascript/(.+)\.js$}) { |m| ""}
    watch(%r{spec/javascript/(.+)\.js$})
  end
end

List of available options:

all_on_start: false                    # Run all specs after changed specs pass.
keep_failed: true                      # Keep failed files until they pass (add them to new ones)
notification: true                     # Display notification always when jest completes.
                                       # If you want to notify only on failure, set to :failure.
cli: nil                               # Additional command-line options to pass to jest.
                                       # Don't use the '-f' or '--format' option here.
command: 'jest'                        # Specify a custom path to the jest command.
default_paths: ['**/*.js', '**/*.es6'] # The default paths that will be used for "all_on_start".

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/RobinDaugherty/guard-jest_runner.

  • Please create a topic branch for every separate change you make.
  • Make sure your patches are well-tested.
  • Update the README to reflect your changes.
  • Please do not change the version number.
  • Open a pull request.