README.md in sewing_kit-0.93.0 vs README.md in sewing_kit-0.94.0

- old
+ new

@@ -177,9 +177,42 @@ }); ``` For more complete documentation of the jest plugin see [it's documentation](/docs/plugins/jest.md). +### Rails tests + +Building JavaScript assets for Rails tests adds friction to test driven development, but some projects rely on tests that intermingle erb / JavaScript behaviour. To accommodate different test styles, sewing_kit offers two test modes. + +#### `:return_no_assets` - sewing_kit helpers return empty arrays (default) + +As noted above, the Web Foundation team highly recommends `sewing-kit test` for front end testing. Projects following this recommendation can use sewing_kit's default behaviour for controller, integration tests, and e2e tests. Note that no sewing_kit content will appear in pages with this mode enabled. + +The default behaviour is equivalent to this configuration: + +```rb +# config/initializers/sewing_kit.rb +SewingKit.configure do |config| + config.test_manifest_mode = :return_no_asets +end +``` + +#### Use precompiled assets + +If end-to-end tests are unavoidable: + +- Add extra steps to your test commands and CI pipelines that run `sewing-kit build --mode test` before test startup +- Configure sewing_kit's `test_manifest_mode` to use precompiled assets: + +```rb +# config/initializers/sewing_kit.rb +SewingKit.configure do |config| + config.test_manifest_mode = :use_precompiled_assets +end +``` + +If your tests require production assets, precompile using `sewing-kit build --mode production` instead. + ## FAQ ### Which version of sewing-kit can I use? Assume that the sewing*kit gem's latest minor version requires \_at least* the same minor version of the sewing-kit package.