Skip to content

Commit d953559

Browse files
committed
test(wtr): remove .only file support for hydration tests
Web Test Runner lets you specify individual files via CLI, so the workaround is not necessary.
1 parent fe48d42 commit d953559

File tree

2 files changed

+3
-27
lines changed

2 files changed

+3
-27
lines changed

packages/@lwc/integration-not-karma/configs/plugins/serve-hydration.js

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import path from 'node:path';
22
import vm from 'node:vm';
3-
import fs from 'node:fs/promises';
43
import { fileURLToPath } from 'node:url';
54
import { rollup } from 'rollup';
65
import lwcRollupPlugin from '@lwc/rollup-plugin';
@@ -21,16 +20,6 @@ const ROOT_DIR = path.join(import.meta.dirname, '../..');
2120
const COMPONENT_NAME = 'x-main';
2221
const COMPONENT_ENTRYPOINT = 'x/main/main.js';
2322

24-
// Like `fs.existsSync` but async
25-
async function exists(path) {
26-
try {
27-
await fs.access(path);
28-
return true;
29-
} catch (_err) {
30-
return false;
31-
}
32-
}
33-
3423
async function compileModule(input, targetSSR, format) {
3524
const modulesDir = path.join(ROOT_DIR, input.slice(0, -COMPONENT_ENTRYPOINT.length));
3625
const bundle = await rollup({
@@ -106,15 +95,6 @@ async function getSsrMarkup(componentEntrypoint, configPath) {
10695
return await script.runInContext(vm.createContext({ LWC: lwcSsr }));
10796
}
10897

109-
async function existsUp(dir, file) {
110-
while (true) {
111-
if (await exists(path.join(dir, file))) return true;
112-
dir = path.join(dir, '..');
113-
const basename = path.basename(dir);
114-
if (basename === '.') return false;
115-
}
116-
}
117-
11898
/**
11999
* Hydration test `index.spec.js` files are actually config files, not spec files.
120100
* This function wraps those configs in the test code to be executed.
@@ -129,8 +109,6 @@ async function wrapHydrationTest(configPath) {
129109

130110
const suiteDir = path.dirname(configPath);
131111
const componentEntrypoint = path.join(suiteDir, COMPONENT_ENTRYPOINT);
132-
// You can add an `.only` file alongside an `index.spec.js` file to make the test focused
133-
const onlyFileExists = await existsUp(suiteDir, '.only');
134112
const ssrOutput = await getSsrMarkup(componentEntrypoint, configPath);
135113

136114
return `
@@ -139,8 +117,7 @@ async function wrapHydrationTest(configPath) {
139117
runTest(
140118
'/${configPath}?original=1',
141119
'/${componentEntrypoint}',
142-
${JSON.stringify(ssrOutput) /* escape quotes */},
143-
${onlyFileExists}
120+
${JSON.stringify(ssrOutput) /* escape quotes */}
144121
);
145122
`;
146123
} finally {

packages/@lwc/integration-not-karma/configs/plugins/test-hydration.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ function setFeatureFlags(requiredFeatureFlags, value) {
4545
}
4646

4747
// Must be sync to properly register tests; async behavior can happen in before/after blocks
48-
export function runTest(configPath, componentPath, ssrRendered, focused) {
49-
const test = focused ? it.only : it;
48+
export function runTest(configPath, componentPath, ssrRendered) {
5049
const description = new URL(configPath, location.href).pathname;
5150
let consoleSpy;
5251
let testConfig;
@@ -70,7 +69,7 @@ export function runTest(configPath, componentPath, ssrRendered, focused) {
7069
setFeatureFlags(testConfig.requiredFeatureFlags, false);
7170
});
7271

73-
test(description, async () => {
72+
it(description, async () => {
7473
const container = appendTestTarget(ssrRendered);
7574
const selector = container.firstChild.tagName.toLowerCase();
7675
let target = container.querySelector(selector);

0 commit comments

Comments
 (0)