Skip to content

Commit 859cab5

Browse files
Fail on error in JavascriptPackageTest for UJS
Prior to this commit, if `app/javascript/rails-ujs/index.js` contained a syntax error, `JavascriptPackageTest` would still pass because `system "yarn build"` would simply return `false` and the compiled output would not change. This commit adds `exception: true` to the `system` call so that an error will be raised if `yarn build` fails.
1 parent febd21d commit 859cab5

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

actionview/test/javascript_package_test.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
class JavascriptPackageTest < ActiveSupport::TestCase
44
def test_compiled_code_is_in_sync_with_source_code
5-
assert_no_changes -> {
6-
%w[
7-
app/assets/javascripts/rails-ujs.js
8-
app/assets/javascripts/rails-ujs.esm.js
9-
].map { |compiled_file|
10-
File.read(File.expand_path("../#{compiled_file}", __dir__))
11-
}
12-
} do
13-
system "yarn build"
5+
compiled_files = %w[
6+
app/assets/javascripts/rails-ujs.js
7+
app/assets/javascripts/rails-ujs.esm.js
8+
].map do |file|
9+
Pathname(file).expand_path("#{__dir__}/..")
10+
end
11+
12+
assert_no_changes -> { compiled_files.map(&:read) } do
13+
system "yarn build", exception: true
1414
end
1515
end
1616
end

0 commit comments

Comments
 (0)