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

Breaking: Integrate with window.history, add setter method on window.location, improve tests and other project meta #179

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

Conversation

evelynhathaway
Copy link
Owner

Breaking

Improvements

Internal

  • Chore: Simplify GitHub Actions npm cache

  • Chore: Remove extraneous eslint disables

  • Chore: Improve tests for existing logic

@evelynhathaway evelynhathaway added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels Oct 19, 2023
Copy link
Owner Author

Choose a reason for hiding this comment

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

This file is where are majority of the net new value is.

We "replace" the history with a proxy to automatically update after any method is called. I could have made this an equally hacky replacement of each method with a spy that composes itself with an update function, but proxies are fun. (I wish Jest spies had events)

Jest spies on the methods on the proxy to provide access to call data to testers.

Comment on lines +34 to +36
set (value: string) {
locationMock.href = value;
},
Copy link
Owner Author

Choose a reason for hiding this comment

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

I didn't implement the setter on the first go of this library. Mostly because I don't use it instead of the many other options like window.location.href = and forgot! TypeScript's typings are also borked here, so maybe I am not alone lol.

This is technically a breaking change, so I am glad it can be lumped together with window.history support

evelynhathaway and others added 5 commits October 19, 2023 18:49
## v3.0.0-alpha.1

**[`v2.0.0...v3.0.0-alpha.1`](v2.0.0...v3.0.0-alpha.1)** - **2023-10-20**

### 💥 Breaking

- Add setter method on window.location [`4be68a0`](4be68a0)
- Add spies and proxy for window.history to track its updates to the original window.location [`628a60d`](628a60d)

### 📄 Documentation

- Add limitations, new features, alternative setup and configuration methods to readme [`51a65bf`](51a65bf)
- Fix comma typos in readme [`8f9af49`](8f9af49)

### 📦 Package

- **npm:** Bump jest-diff from 29.6.4 to 29.7.0 [`d592844`](d592844)
- **npm:** npm update deep [`26652b8`](26652b8)

### 🧹 Internal

- Downgrade semantic-release [`774ada3`](774ada3)
- Improve tests for existing logic [`8ef5de8`](8ef5de8)
- Remove extraneous eslint disables [`e3401af`](e3401af)
- Simplify GitHub Actions npm cache [`0a0441c`](0a0441c)
- Update GitHub Actions [`ed50b4d`](ed50b4d)
@evelynhathaway
Copy link
Owner Author

jsdom v23.1.0 has changed the history behavior. I should check to see what impact that may have to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

window.history.pushState not working as expected Conflicts with other tests, Possibly React Router v6
2 participants