Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add frame router tests #287

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add frame router tests #287

wants to merge 2 commits into from

Conversation

MattCheely
Copy link
Collaborator

In looking at #271, I discovered some corner cases where behavior was changing. I was also able to get unit testing working for the underlying behavior, so I've opened the PR to add the unit tests and verify they are correct for the current release. This will capture the (admittedly inconsistent) current behavior of the library. We can merge this and use it to refine the work in the query fix PR to ensure no regressions.

envData: ENV_DATA,
};
//@ts-ignore
expect(router._envData).toEqual({
Copy link
Collaborator

Choose a reason for hiding this comment

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

"_envData" is accessible here? I thought it was a private variable

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In TypeScript private is only meaningful within the type system. Because TS has to compile to vanilla JS, which has no direct concept of private, it just becomes a regular property on the object. That means it's accessible in tests by disabling the type checks for that line.

It's not a pattern I'd generally recommend though, and on the next major release when we're doing significant refactors, we should look for ways to make this testable without having to ignore type checks.

@MattCheely
Copy link
Collaborator Author

Looks like I accidentally updated package-lock.json to point at our internal npm repo. I'll fix that and update the PR today.

This resolves some bugs with testing custom element code
…ehavior

This behavior is somewhat inconsistent and should be re-worked in the future, but this will let us
make small improvements and bugfixes without regressing current behavior in a way that could break
existing usage.
@MattCheely MattCheely force-pushed the add-frame-router-tests branch from 3b64b67 to 8abfc2e Compare January 27, 2025 01:00
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.

2 participants