Skip to content

Commit f2934f8

Browse files
committed
test(wtr): create process.env with only string values
1 parent 716f7b5 commit f2934f8

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

packages/@lwc/integration-not-karma/configs/base.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,24 @@ import { LWC_VERSION } from '@lwc/shared';
33
import * as options from '../helpers/options.js';
44
import { resolvePathOutsideRoot } from '../helpers/utils.js';
55

6+
/**
7+
* We want to convert from parsed options (true/false) to a `process.env` with only strings.
8+
* This drops `false` values and converts everything else to a string.
9+
*/
10+
const envify = (obj) => {
11+
const clone = {};
12+
for (const [key, val] of Object.entries(obj)) {
13+
if (val !== false) {
14+
clone[key] = String(val);
15+
}
16+
}
17+
return clone;
18+
};
619
const pluck = (obj, keys) => Object.fromEntries(keys.map((k) => [k, obj[k]]));
720
const maybeImport = (file, condition) => (condition ? `await import('${file}');` : '');
821

922
/** `process.env` to inject into test environment. */
10-
const env = {
23+
const env = envify({
1124
...pluck(options, [
1225
'API_VERSION',
1326
'DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE',
@@ -21,7 +34,7 @@ const env = {
2134
]),
2235
LWC_VERSION,
2336
NODE_ENV: options.NODE_ENV_FOR_TEST,
24-
};
37+
});
2538

2639
/** @type {import("@web/test-runner").TestRunnerConfig} */
2740
export default {

packages/@lwc/integration-not-karma/test/shadow-dom/Node-properties/Node.hasChildNodes.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('Node.hasChildNodes', () => {
2626

2727
expect(container.shadowRoot.querySelector('.container').hasChildNodes()).toBe(true);
2828
expect(container.shadowRoot.querySelector('slot').hasChildNodes()).toBe(
29-
process.env.NATIVE_SHADOW
29+
Boolean(process.env.NATIVE_SHADOW)
3030
);
3131
});
3232
});

0 commit comments

Comments
 (0)