Skip to content

Commit e6efc34

Browse files
test(wtr): remove unnecessary support for .only files @W-19098252 (#5513)
* test(wtr): update tests to use relative path to utils instead of weird fake module * test(wtr): revert removing TestUtils * test(wtr): remove useless describe There's no setup/teardown needed, it's a single test, and WTR provides per-file encapsulation * test(wtr): replace IIFE script with module import * test(wtr): clean up SSR execution script working toward just importing and executing things, but not quite there yet * test(wtr): always use DISABLE_SYNTHETIC two env vars for the same goal is unnecessary * test(wtr): enable all hydration tests I think the last one was a concurrency related timeout, which was previously addressed. * test(wtr): remove side effect from signals helper helper files shouldn't have side effects; all setup should be in the setup file * test(wtr): import directly from file, not from barrel exporter * test(wtr): change bulk export statement to individual exports * test(wtr): remove unnecessary aria re-export * test(wtr): fix a few more ARIA util imports * chore: move comment for nicer aesthetic * test(wtr): remove unused option * test(wtr): fix another ARIA util import * test(wtr): import directly from hooks file rather than utils * test(wtr): import directly from signals file rather than utils * test(wtr): import directly from console helper rather than utils * test(wtr): import directly from constants helper rather than utils * test(wtr): only import what is needed from LWC * test(wtr): split lwc:dynamic load helpers into separate file * test(wtr): avoid relying on global LWC * test(wtr): remove unnecessary wrapping of hydration test config * test(wtr): remove test-utils logic from resolveImport no longer necessary * test(wtr): move plugin from shared config to only config that uses it * test(wtr): remove useless guid all tests are run in isolation * test(wtr): remove unnecessary test-utils global * test(wtr): clean up component definition * test(wtr): change component in test from IIFE to import * test(wtr): shift logic out of wrapper into static test runner file we want to keep the generated wrappers as thin as possible and use regular js files as much as possible * test(wtr): make test setup/teardown more idiomatic * test(wtr): clean up module compilation * chore(wtr): make dependency on @vitest/spy explicit * test(wtr): remove console suppression It was originally implemented to suppress distracting warnings in Karma tests, but WTR's log output is different / managed differently. * test(wtr): clean up names and comments * test(wtr): move and rename file * test(wtr): remove usage of global TestUtils from hydration tests * test(wtr): remove LWC import from utils It breaks hydration tests if there's an import from LWC. * test(wtr): remove unused external deps * test(wtr): use imports instead of jasmine globals * chore(eslint): remove unused rule config * fix: attribute cte syntax in integration tests * test(wtr): fix case in import mismatched case passes locally, but causes issues in CI * test(wtr): re-enable tests that used to fail in CI they should all work now * test(wtr): enable browser logs * test(wtr): name plugins helpful when debugging * test(wtr): rename variables and document functions for clarity * test(wtr): convert promise chains to async/await * test(wtr): load code from known url, rather than sniffing script tag * test(wtr): convert LWC from iife to fake cjs * test(wtr): remove unnecessary wrapping * test(wtr): data can be data, not a function * test(wtr): replace `evaluate` with functions that require less wrapping * test(wtr): only fetch scripts once * test(wtr): john was here * test(wtr): add line breaks and vars for clarity * test(wtr): rename variable it's just one code blob now, not multiple scripts * test(wtr): fix param pass through * test(wtr): more cleanup * test(wtr): remove outdated comment * test(wtr): avoid shadowing global var ensures we never accidentally use the wrong one * test(wtr): enable custom element registry tests * test(wtr): hoist function definition * chore: use vitest spy instead of custom hack * test(wtr): use vitest spy instead of custom * test(wtr): convert test to async/await * test(wtr): use vitest spy instead of custom * test(wtr): move util into only file that uses it * 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. * test(wtr): disable browser logs for more readable output * Revert "test(wtr): disable browser logs for more readable output" This reverts commit 56a39c7. --------- Co-authored-by: John Hefferman <jhefferman@salesforce.com>
1 parent 8fb80db commit e6efc34

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)