Skip to content

Commit 2417ac6

Browse files
author
Takashi Kato
committed
Update README.md
1 parent 96fb1fc commit 2417ac6

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
This plugin makes it easy to test ES modules with [importmap-rails](https://github.com/rails/importmap-rails) when using Rails 7 or later.
44
It integrates the [Mocha](https://mochajs.org/) JavaScript testing library (using [Chai](https://www.chaijs.com/) as the assertion library, [@mswjs/interceptors](https://github.com/mswjs/interceptors) as the mocking library) and runs tests for ES modules delivered with importmap in the browser.
55

6+
[More useful in combination with the rails_live_reload gem](#use-with-rails_live_reload-gem)
7+
68
# Installation
79

810
Assuming you have already installed importmap-rails with Rails 7, add the following to your Gemfile and run `bundle install`.
@@ -85,6 +87,39 @@ describe('clear controller', () => {
8587
* config.importmap_mocha_path: The location where the test code is stored. Default is `test/javascripts` and `spec/javascripts`.
8688
* config.importmap_mocha_scripts: The scripts to be loaded globally. e.g. `['jquery.js']`.
8789

90+
# Use with Rails_Live_Reload gem
91+
92+
It is strongly recommended to use with [rails_live_reload](https://github.com/railsjazz/rails_live_reload)
93+
94+
![](./images/screencast01.gif)
95+
96+
Add this line to your application's Gemfile:
97+
98+
```ruby
99+
group :development do
100+
gem "importmap_mocha_rails"
101+
gem "rails_live_reload"
102+
end
103+
```
104+
105+
And then execute:
106+
107+
```
108+
bundle install
109+
rails generate rails_live_reload:install
110+
```
111+
112+
Edit initializer
113+
```ruby
114+
# frozen_string_literal: true
115+
116+
RailsLiveReload.configure do |config|
117+
config.watch %r{app/views/.+\.(erb|haml|slim)$}
118+
# Monitor JavaScript tests in addition to default paths
119+
config.watch %r{(app|vendor|test)/(assets|javascript|javascripts)/\w+/(.+\.(css|js|html|png|jpg|ts|jsx)).*}, reload: :always
120+
end if defined?(RailsLiveReload)
121+
```
122+
88123
# Author
89124

90125
Takashi Kato tohosaku@users.osdn.me

images/screencast01.gif

1.61 MB
Loading

0 commit comments

Comments
 (0)