vite-plugin-testem 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/index.js +18 -1
- package/package.json +2 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.1] - 2026-04-19
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **`createTestemViteMiddleware`:** Strip Testem’s per-browser URL prefix (`/<sessionId>/…`) before forwarding to Vite so the runner page and assets resolve correctly when Testem opens `/:id/tests_run.html` (fixes “testem.js not loaded” / connection timeout in CI).
|
|
13
|
+
|
|
14
|
+
## [1.0.0] - 2026-04-19
|
|
15
|
+
|
|
16
|
+
First stable release: Vite plugin and Testem middleware helper for browser tests.
|
|
17
|
+
|
|
18
|
+
### Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install vite-plugin-testem --save-dev
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Install a compatible **Vite** version (peer dependency: `^7.0.0 || ^8.0.0`). To run browser tests with Testem, install **Testem** (optional peer: `^3.20.0`):
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install testem@^3.20.0 --save-dev
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Links
|
|
31
|
+
|
|
32
|
+
- **npm:** [vite-plugin-testem](https://www.npmjs.com/package/vite-plugin-testem)
|
|
33
|
+
- **Docs:** [README on GitHub](https://github.com/Gaurav0/vite-plugin-testem#readme)
|
package/index.js
CHANGED
|
@@ -47,6 +47,7 @@ Testem.handleConsoleMessage = function (msg) {
|
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Creates Express middleware (for Testem `middleware:`) that forwards requests to Vite in middleware mode.
|
|
50
|
+
* Strips Testem’s per-browser session prefix (`/:id/…`) so Vite resolves paths from the project root.
|
|
50
51
|
* Skips `/testem.js`, `/testem/*`, and `/socket.io` so Testem’s own routes run later in the stack.
|
|
51
52
|
*
|
|
52
53
|
* @param {import('vite').InlineConfig} [inlineConfig] merged after defaults; set `configFile: false` to skip loading `vite.config.js`
|
|
@@ -76,7 +77,23 @@ async function createTestemViteMiddleware(inlineConfig = {}) {
|
|
|
76
77
|
|
|
77
78
|
function middleware(app) {
|
|
78
79
|
app.use((req, res, next) => {
|
|
79
|
-
|
|
80
|
+
let url = req.url;
|
|
81
|
+
const qIdx = url.indexOf('?');
|
|
82
|
+
const pathPart = qIdx === -1 ? url : url.slice(0, qIdx);
|
|
83
|
+
const queryPart = qIdx === -1 ? '' : url.slice(qIdx);
|
|
84
|
+
// Testem opens the runner under /:id/… (browser session). Strip it so Vite resolves files
|
|
85
|
+
// from project root (same path layout as bare /tests_run.html).
|
|
86
|
+
const withPath = pathPart.match(/^\/-?\d+\/(.+)$/);
|
|
87
|
+
const idOnly = pathPart.match(/^\/-?\d+$/);
|
|
88
|
+
if (withPath) {
|
|
89
|
+
req.url = `/${withPath[1]}${queryPart}`;
|
|
90
|
+
url = req.url;
|
|
91
|
+
} else if (idOnly) {
|
|
92
|
+
req.url = `/${queryPart}`;
|
|
93
|
+
url = req.url;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const pathname = url.split('?')[0];
|
|
80
97
|
if (
|
|
81
98
|
pathname === '/testem.js' ||
|
|
82
99
|
pathname.startsWith('/testem/') ||
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-testem",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Vite plugin and Testem middleware helper for running browser tests with Testem",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"files": [
|
|
32
32
|
"index.js",
|
|
33
33
|
"README.md",
|
|
34
|
+
"CHANGELOG.md",
|
|
34
35
|
"LICENSE"
|
|
35
36
|
],
|
|
36
37
|
"peerDependencies": {
|