Skip to content

Conversation

@wjhsf
Copy link
Contributor

@wjhsf wjhsf commented Jul 15, 2025

Details

I cleaned up the organization of the config files a bit, plus a mishmash of things to get more of the tests passing.

Before these changes, we had 2769 tests passing in 248 files. After these changes, we have 3194 tests passing in 297 files.

Does this pull request introduce a breaking change?

  • 😮‍💨 No, it does not introduce a breaking change.
  • 💔 Yes, it does introduce a breaking change.

Does this pull request introduce an observable change?

  • 🤞 No, it does not introduce an observable change.
  • 🔬 Yes, it does include an observable change.

GUS work item

wjhsf and others added 30 commits June 23, 2025 11:25
everything passed first try, which is kinda sus
# Conflicts:
#	packages/@lwc/integration-not-karma/helpers/wtr-utils.mjs
code is now in helpers/matchers/index.mjs
reduces test failures from 291 to 220
who needs convention?
@wjhsf wjhsf requested a review from a team as a code owner July 15, 2025 14:38
});
}

beforeAll(function () {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toEqualWireSettings is never actually used anywhere.

Comment on lines +28 to +29
expect(args[i][0]).toBeInstanceOf(Error);
expect(args[i][0].message).toMatch(regexes[i]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Karma's toMatch coerces the received value (in this case, an error) to a string, but the setup we have for web-test-runner expects to receive only a string.

describe('wiring', () => {
describe('component lifecycle and wire adapter', () => {
it('should call a connect when component is connected', () => {
it('should call a connect when component is connected', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests in this file use a shared global state. Most of the tests, but not all, have asynchronous behavior. In Karma, the state was properly cleaned for both sync and async tests. With web-test-runner, the state got polluted with the synchronous tests. Converting the sync tests to async functions (even with no inner await/promises) solved the problem, although I don't fully understand why.

Note that I added async to all the functions, not just the sync ones, because that's best practice for anything that returns a promise.

if (ctx.path.endsWith('.spec.js') && !ctx.query.original) {
return await wrapHydrationTest(ctx.path.slice(1)); // remove leading /
// `/__wds-outside-roout__/${depth}/` === '../'.repeat(depth)
return '/__wds-outside-root__/1/wire-service/dist/index.js';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out what I originally had never actually worked. 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this path, is that where modules compiled by wtr ends up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a magic path that WTR1 uses to serve files that exist outside the web root (the package directory). In our case, it's primarily used by WTR for resolving node_modules in the monorepo root. I think it's mostly intended as an internal detail to make node imports "just work", so this solution is a bit of a hack.

1 technically @web/dev-server, hence wds

return '@lwc/wire-service';
}
},
async serve(ctx) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

serve is moved to a separate plugin file, since it is different for regular tests vs hydration tests.

Comment on lines +1 to +2
// Use native shadow by default in hydration tests; MUST be set before imports
process.env.DISABLE_SYNTHETIC ??= 'true';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's probably a more idiomatic way of doing this, but the hack works for now. 🤷

@wjhsf wjhsf changed the title test(integration): more web-test-runner test fixes test(integration): more web-test-runner test fixes @W-18763051 Jul 15, 2025
tests manipulate the body, so we use head for scripts to keep the body clean
if (ctx.path.endsWith('.spec.js') && !ctx.query.original) {
return await wrapHydrationTest(ctx.path.slice(1)); // remove leading /
// `/__wds-outside-roout__/${depth}/` === '../'.repeat(depth)
return '/__wds-outside-root__/1/wire-service/dist/index.js';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this path, is that where modules compiled by wtr ends up?

Base automatically changed from wjh/more-wtr to master July 16, 2025 15:09
@wjhsf wjhsf enabled auto-merge (squash) July 16, 2025 15:12
@wjhsf wjhsf merged commit 3a55c27 into master Jul 16, 2025
6 checks passed
@wjhsf wjhsf deleted the wjh/even-more-wtr branch July 16, 2025 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants