Skip to content

Commit 776b3f9

Browse files
authored
Don't enhance test:prepare unless it exists (#12)
* Don't enhance test:prepare unless it exists * Document need to run javascript:build before test suite when test:prepare is not defined
1 parent b78a32c commit 776b3f9

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ When you deploy your application to production, the `javascript:build` task atta
88

99
This also happens in testing where the bundler attaches to the `test:prepare` task to ensure the JavaScript has been bundled before testing commences. (Note that this currently only applies to rails `test:*` tasks (like `test:all` or `test:controllers`), not "rails test", as that doesn't load `test:prepare`).
1010

11+
If your testing library of choice does not define a `test:prepare` Rake task, ensure that your test suite runs `javascript:build` to bundle JavaScript before testing commences.
12+
1113
That's it!
1214

1315
You can configure your bundler options in the `build` script in `package.json` or via the installer-generated `rollup.config.js` for rollup.js or `webpack.config.json` for Webpack (esbuild does not have a default configuration format).

lib/tasks/jsbundling/build.rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ namespace :javascript do
66
end
77

88
Rake::Task["assets:precompile"].enhance(["javascript:build"])
9-
Rake::Task["test:prepare"].enhance(["javascript:build"])
9+
Rake::Task["test:prepare"].enhance(["javascript:build"]) if Rake::Task.task_defined?("test:prepare")

0 commit comments

Comments
 (0)