@stencil/vitest 1.9.1 → 1.9.3
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/dist/bin/stencil-test.js +25 -3
- package/dist/testing/render.js +14 -14
- package/package.json +2 -2
package/dist/bin/stencil-test.js
CHANGED
|
@@ -3,6 +3,28 @@ import { spawn } from 'child_process';
|
|
|
3
3
|
import { existsSync, unlinkSync, writeFileSync } from 'fs';
|
|
4
4
|
import { extname, join } from 'path';
|
|
5
5
|
import { createJiti } from 'jiti';
|
|
6
|
+
/**
|
|
7
|
+
* Creates a clean environment for spawning npm/npx commands.
|
|
8
|
+
* Filters out pnpm-specific npm_config_* variables that npm doesn't recognize,
|
|
9
|
+
* which cause warnings like "Unknown env config" in npm 10+.
|
|
10
|
+
*/
|
|
11
|
+
function getCleanNpmEnv(extraEnv = {}) {
|
|
12
|
+
const pnpmOnlyConfigs = new Set([
|
|
13
|
+
'npm_config_npm-globalconfig',
|
|
14
|
+
'npm_config_verify-deps-before-run',
|
|
15
|
+
'npm_config_catalog',
|
|
16
|
+
'npm_config__jsr-registry',
|
|
17
|
+
'npm_config_only-built-dependencies',
|
|
18
|
+
'npm_globalconfig_only-built-dependencies',
|
|
19
|
+
]);
|
|
20
|
+
const cleanEnv = {};
|
|
21
|
+
for (const [key, value] of Object.entries(process.env)) {
|
|
22
|
+
if (!pnpmOnlyConfigs.has(key)) {
|
|
23
|
+
cleanEnv[key] = value;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return { ...cleanEnv, ...extraEnv };
|
|
27
|
+
}
|
|
6
28
|
function parseArgs(argv) {
|
|
7
29
|
const parsed = {
|
|
8
30
|
watch: false,
|
|
@@ -235,14 +257,13 @@ function runTests() {
|
|
|
235
257
|
cwd,
|
|
236
258
|
stdio: 'inherit',
|
|
237
259
|
shell: true,
|
|
238
|
-
env: {
|
|
239
|
-
...process.env,
|
|
260
|
+
env: getCleanNpmEnv({
|
|
240
261
|
NODE_ENV: 'test',
|
|
241
262
|
// Expose CLI flags to tests via environment variables
|
|
242
263
|
STENCIL_PROD: args.prod ? 'true' : '',
|
|
243
264
|
STENCIL_SERVE: args.serve ? 'true' : '',
|
|
244
265
|
STENCIL_PORT: args.port || '',
|
|
245
|
-
},
|
|
266
|
+
}),
|
|
246
267
|
});
|
|
247
268
|
vitestProcess.on('exit', (code) => {
|
|
248
269
|
isRunningTests = false;
|
|
@@ -631,6 +652,7 @@ process.on('SIGTERM', () => cleanup());
|
|
|
631
652
|
stencilProcess = spawn('npx', stencilArgs, {
|
|
632
653
|
cwd,
|
|
633
654
|
shell: true,
|
|
655
|
+
env: getCleanNpmEnv(),
|
|
634
656
|
});
|
|
635
657
|
// Pipe stdout and watch for build completion
|
|
636
658
|
stencilProcess.stdout?.on('data', handleStencilOutput);
|
package/dist/testing/render.js
CHANGED
|
@@ -172,19 +172,6 @@ export async function render(template, options = {
|
|
|
172
172
|
if (!element) {
|
|
173
173
|
throw new Error('Failed to render component');
|
|
174
174
|
}
|
|
175
|
-
// Wait for custom element to be defined
|
|
176
|
-
const tagName = element.tagName.toLowerCase();
|
|
177
|
-
if (tagName.includes('-')) {
|
|
178
|
-
await customElements.whenDefined(tagName);
|
|
179
|
-
}
|
|
180
|
-
// Wait for component to be ready
|
|
181
|
-
if (typeof element.componentOnReady === 'function') {
|
|
182
|
-
await element.componentOnReady();
|
|
183
|
-
}
|
|
184
|
-
// Clear per-render spy config after component is ready
|
|
185
|
-
if (options.spyOn) {
|
|
186
|
-
setRenderSpyConfig(null);
|
|
187
|
-
}
|
|
188
175
|
// Define waitForChanges first so we can use it in the ready check
|
|
189
176
|
function waitForChanges(documentElement = element) {
|
|
190
177
|
return new Promise((resolve) => {
|
|
@@ -219,11 +206,24 @@ export async function render(template, options = {
|
|
|
219
206
|
}
|
|
220
207
|
// Wait for component to be fully rendered if requested (default: true)
|
|
221
208
|
if (options.waitForReady !== false) {
|
|
209
|
+
// Wait for custom element to be defined
|
|
210
|
+
const tagName = element.tagName.toLowerCase();
|
|
211
|
+
if (tagName.includes('-')) {
|
|
212
|
+
await customElements.whenDefined(tagName);
|
|
213
|
+
}
|
|
214
|
+
// Wait for component to be ready
|
|
215
|
+
if (typeof element.componentOnReady === 'function') {
|
|
216
|
+
await element.componentOnReady();
|
|
217
|
+
}
|
|
222
218
|
// Wait for Stencil's hydration flag (skipped if hydration disabled)
|
|
223
219
|
await waitForHydrated(element);
|
|
224
|
-
//
|
|
220
|
+
// Wait for Stencil's update cycle to complete
|
|
225
221
|
await waitForChanges();
|
|
226
222
|
}
|
|
223
|
+
// Clear per-render spy config after component is ready
|
|
224
|
+
if (options.spyOn) {
|
|
225
|
+
setRenderSpyConfig(null);
|
|
226
|
+
}
|
|
227
227
|
const setProps = async (newProps) => {
|
|
228
228
|
Object.entries(newProps).forEach(([key, value]) => {
|
|
229
229
|
element[key] = value;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"type": "git",
|
|
5
5
|
"url": "https://github.com/stenciljs/vitest"
|
|
6
6
|
},
|
|
7
|
-
"version": "1.9.
|
|
7
|
+
"version": "1.9.3",
|
|
8
8
|
"description": "First-class testing utilities for Stencil design systems with Vitest",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"type": "module",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"dependencies": {
|
|
101
101
|
"jiti": "^2.6.1",
|
|
102
102
|
"local-pkg": "^1.1.2",
|
|
103
|
-
"vitest-environment-stencil": "1.9.
|
|
103
|
+
"vitest-environment-stencil": "1.9.3"
|
|
104
104
|
},
|
|
105
105
|
"devDependencies": {
|
|
106
106
|
"@eslint/js": "^9.39.2",
|