Skip to content

Commit 6d5ff63

Browse files
committed
fix(WebpackerTest) reload manifest before running test
1 parent 7d5b9a1 commit 6d5ff63

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

test/react/rails/webpacker_test.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22

33

44
when_webpacker_available do
5-
class ReactRailsUJSTest < ActionDispatch::IntegrationTest
5+
class ReactRailsWebpackerTest < ActionDispatch::IntegrationTest
66
include Capybara::DSL
77

88
setup do
99
Capybara.current_driver = Capybara.javascript_driver
1010
end
1111

12+
teardown do
13+
clear_webpacker_packs
14+
end
15+
1216
test 'it mounts pages from the pack' do
1317
visit '/pack_component'
1418
assert page.has_content?('Export Default')

test/test_helper.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,21 @@ def when_sprockets_available
133133

134134
def when_webpacker_available
135135
if defined?(Webpacker)
136+
clear_webpacker_packs
136137
Dir.chdir("./test/dummy") do
137138
Rake::Task['webpacker:compile'].invoke
138139
end
140+
# Reload cached JSON manifest:
141+
Webpacker::Manifest.load
139142
yield
140143
end
141144
end
142145

146+
def clear_webpacker_packs
147+
packs_directory = File.expand_path("../dummy/public/packs", __FILE__)
148+
FileUtils.rm_rf(packs_directory)
149+
end
150+
143151
def fetch_asset_body(asset_logical_path)
144152
Rails.application.assets[asset_logical_path].to_s
145153
end

0 commit comments

Comments
 (0)