vite-plugin-testem 1.0.1 → 1.0.2

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 CHANGED
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ## [1.0.2] - 2026-10-07
11
+
12
+ ### Changed
13
+
14
+ - Optional `testem` peer range is now `^3.20.0 || ^4.0.0-beta.1`. `^4.0.0` does not match `4.0.0-beta.1`.
15
+ - Node.js engines are `^20.19.0 || ^22.12.0 || ^24.0.0 || >=26.0.0`. Node 25 is not supported.
16
+
17
+ ### Fixed
18
+
19
+ - **`createTestemViteMiddleware`:** Transform `*.html` with Vite so `vitePluginTestem` injection runs in middleware mode. `appType` stays `custom`, so paths Vite does not serve still fall through to Testem.
20
+
8
21
  ## [1.0.1] - 2026-04-19
9
22
 
10
23
  ### Fixed
package/README.md CHANGED
@@ -8,12 +8,16 @@
8
8
  npm install vite-plugin-testem --save-dev
9
9
  ```
10
10
 
11
+ Node.js `^20.19.0 || ^22.12.0 || ^24.0.0 || >=26.0.0` is required.
12
+
11
13
  You must also install a compatible Vite version (peer dependency: `^7.0.0 || ^8.0.0`).
12
14
 
13
- To run browser tests with Testem, install Testem in your project (optional peer dependency: `^3.20.0`):
15
+ To run browser tests with Testem, install Testem in your project (optional peer dependency: `^3.20.0 || ^4.0.0-beta.1`):
14
16
 
15
17
  ```bash
16
18
  npm install testem@^3.20.0 --save-dev
19
+ # or, on Node ^22.17.0 || ^24.0.0 || >=26.0.0:
20
+ npm install testem@^4.0.0-beta.1 --save-dev
17
21
  ```
18
22
 
19
23
  ## `vitePluginTestem(options)`
@@ -65,6 +69,16 @@ module.exports = async function testemConfig() {
65
69
  };
66
70
  ```
67
71
 
72
+ ## Development
73
+
74
+ `npm test` runs the smoke test. It does not need Testem or a browser.
75
+
76
+ `npm run test:integration` installs Testem into `fixtures/integration` and runs headless Chrome. `TESTEM_VERSION` defaults to `3.20.0`. Testem 4 needs Chrome and Node `^22.17.0 || ^24.0.0 || >=26.0.0`:
77
+
78
+ ```bash
79
+ TESTEM_VERSION=4.0.0-beta.1 npm run test:integration
80
+ ```
81
+
68
82
  ## License
69
83
 
70
84
  MIT
package/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ const fs = require('fs/promises');
3
4
  const path = require('path');
4
5
  const vite = require('vite');
5
6
 
@@ -48,6 +49,8 @@ Testem.handleConsoleMessage = function (msg) {
48
49
  /**
49
50
  * Creates Express middleware (for Testem `middleware:`) that forwards requests to Vite in middleware mode.
50
51
  * Strips Testem’s per-browser session prefix (`/:id/…`) so Vite resolves paths from the project root.
52
+ * Transforms `*.html` with `server.transformIndexHtml` so plugins such as `vitePluginTestem` run.
53
+ * `appType: 'custom'` stays in place so a missing file falls through to Testem instead of Vite’s 404.
51
54
  * Skips `/testem.js`, `/testem/*`, and `/socket.io` so Testem’s own routes run later in the stack.
52
55
  *
53
56
  * @param {import('vite').InlineConfig} [inlineConfig] merged after defaults; set `configFile: false` to skip loading `vite.config.js`
@@ -101,6 +104,29 @@ async function createTestemViteMiddleware(inlineConfig = {}) {
101
104
  ) {
102
105
  return next();
103
106
  }
107
+
108
+ if (pathname.endsWith('.html')) {
109
+ const rootPath = path.resolve(cwd);
110
+ const filePath = path.resolve(rootPath, pathname.slice(1));
111
+ const relative = path.relative(rootPath, filePath);
112
+ if (!relative.startsWith('..') && !path.isAbsolute(relative)) {
113
+ fs.readFile(filePath, 'utf8')
114
+ .then((html) => server.transformIndexHtml(url, html))
115
+ .then((html) => {
116
+ res.statusCode = 200;
117
+ res.setHeader('Content-Type', 'text/html; charset=utf-8');
118
+ res.end(html);
119
+ })
120
+ .catch((err) => {
121
+ if (err && err.code === 'ENOENT') {
122
+ return server.middlewares(req, res, next);
123
+ }
124
+ return next(err);
125
+ });
126
+ return;
127
+ }
128
+ }
129
+
104
130
  server.middlewares(req, res, next);
105
131
  });
106
132
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-testem",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Vite plugin and Testem middleware helper for running browser tests with Testem",
5
5
  "keywords": [
6
6
  "vite",
@@ -19,7 +19,7 @@
19
19
  "url": "https://github.com/Gaurav0/vite-plugin-testem/issues"
20
20
  },
21
21
  "engines": {
22
- "node": "^20.19.0 || ^22.12.0 || >=24.0.0"
22
+ "node": "^20.19.0 || ^22.12.0 || ^24.0.0 || >=26.0.0"
23
23
  },
24
24
  "main": "./index.js",
25
25
  "exports": {
@@ -36,7 +36,7 @@
36
36
  ],
37
37
  "peerDependencies": {
38
38
  "vite": "^7.0.0 || ^8.0.0",
39
- "testem": "^3.20.0"
39
+ "testem": "^3.20.0 || ^4.0.0-beta.1"
40
40
  },
41
41
  "peerDependenciesMeta": {
42
42
  "testem": {
@@ -45,7 +45,8 @@
45
45
  },
46
46
  "scripts": {
47
47
  "lint": "eslint .",
48
- "test": "node scripts/smoke-test.js"
48
+ "test": "node scripts/smoke-test.js",
49
+ "test:integration": "node scripts/integration-test.js"
49
50
  },
50
51
  "devDependencies": {
51
52
  "@eslint/js": "^10.0.0",