Skip to content

Commit e253bba

Browse files
committed
feat: enable hmr when running tests in development with vite dev server
1 parent 61b76e3 commit e253bba

13 files changed

Lines changed: 42 additions & 12 deletions

File tree

docs/config/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ If you followed the [installation] section, it should look similar to:
6666
},
6767
"test": {
6868
"autoBuild": true,
69-
"publicOutputDir": "vite-test"
69+
"publicOutputDir": "vite-test",
70+
"port": 3037
7071
}
7172
}
7273
```

docs/guide/development.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,22 @@ Tag helpers are provided in the framework-specific integrations:
137137
- [Hanami](/guide/hanami)
138138
- [Padrino](/guide/padrino)
139139
- [Plugin Legacy](/guide/plugin-legacy)
140+
141+
## HMR for Integration Tests ✅
142+
143+
When iterating on integration tests locally, you can [avoid rebuilds] by starting
144+
an additional Vite dev server for tests with <kbd>bin/vite dev --mode=test</kbd>.
145+
146+
To reuse the same Vite dev server from development, you can configure <kbd>[publicOutputDir]</kbd> and <kbd>[port]</kbd> in `test` to match the `development` config.
147+
148+
::: tip Intended for quick iteration
149+
The trade-off is that your app might not even build correctly.
150+
151+
It's safe if you are running tests in a CI as it will build in production mode.
152+
153+
When running tests locally, you can test the production build by not starting the Vite dev server for tests, or by setting the `CI` environment varialbe.
154+
:::
155+
156+
[avoid rebuilds]: https://github.com/ElMassimo/vite_ruby/tree/main/examples/rails/spec/features/home_spec.rb#15
157+
[publicOutputDir]: /config/#publicoutputdir
158+
[port]: /config/#port

examples/hanami_bookshelf/config/vite.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"test": {
1212
"autoBuild": true,
13-
"publicOutputDir": "vite-test"
13+
"publicOutputDir": "vite-test",
14+
"port": 3037
1415
}
1516
}

examples/padrino_blog_tutorial/config/vite.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"test": {
1212
"autoBuild": true,
13-
"publicOutputDir": "vite-test"
13+
"publicOutputDir": "vite-test",
14+
"port": 3037
1415
}
1516
}

examples/rails/config/vite.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"test": {
1212
"autoBuild": true,
13-
"publicOutputDir": "vite-test"
13+
"publicOutputDir": "vite-test",
14+
"port": 3037
1415
}
1516
}

test/mounted_app/test/dummy/config/vite.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"test": {
1212
"autoBuild": true,
13-
"publicOutputDir": "vite-test"
13+
"publicOutputDir": "vite-test",
14+
"port": 3037
1415
}
1516
}

vite-plugin-ruby/example/config/vite.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
},
1717
"test": {
1818
"autoBuild": true,
19-
"publicOutputDir": "vite-test"
19+
"publicOutputDir": "vite-test",
20+
"port": 3037
2021
}
2122
}

vite_hanami/templates/config/hanami-vite.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"test": {
1212
"autoBuild": true,
13-
"publicOutputDir": "vite-test"
13+
"publicOutputDir": "vite-test",
14+
"port": 3037
1415
}
1516
}

vite_padrino/templates/config/padrino-vite.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"test": {
1212
"autoBuild": true,
13-
"publicOutputDir": "vite-test"
13+
"publicOutputDir": "vite-test",
14+
"port": 3037
1415
}
1516
}

vite_rails/templates/config/rails-vite.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"test": {
1212
"autoBuild": true,
13-
"publicOutputDir": "vite-test"
13+
"publicOutputDir": "vite-test",
14+
"port": 3037
1415
}
1516
}

0 commit comments

Comments
 (0)