-
Notifications
You must be signed in to change notification settings - Fork 2
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
refactor: make the network shim cypress-plugin based #128
refactor: make the network shim cypress-plugin based #128
Conversation
As discussed on Slack this isn't a blocker now. 😅
Codemods are quite robust and will make it a lot easier to help all apps get up to new versions so I definitely think that if we can supply a codemod to apply the breaking change automatically, we should do so. |
Nice solution on throwing if a parallel run is detected. I think the limitation is OK for now. 👍 Good job. |
b8b67b2
to
6b0d9e8
Compare
@amcgee @Mohammer5 @varl there are some points I am unsure about: POINT 2:
These changes are pretty much undocumented (the only source of information is the example app). Should I take additional steps to make the transition easier? |
Missed that. I will see what I can do. |
@varl in 759dc44 I've made some adjustments in the So what do we do now? I guess these are our options: I'd be in favour of B, but that could be because it's the least amount of work right now, and that shouldn't drive our decisions.... |
If you squash-merge, you must make sure that the final commit message is conventional compliant, the default one used by GitHub is usually not. If you merge, then the commit message is going to trigger a breaking change.
Some documentation would be nice, at the very least in README under an "Migrating from X to Y?" section with the required steps. |
In general, the commit that triggers the change should be structured:
That way, each breaking change shows up in the CHANGELOG, with the steps the consumer needs to take to comply with the breaking changes. |
BREAKING CHANGE: To use the network-shim's functionality the project will need to use the new network shim plugin on top of the existing enableNetworkShim setup. Also, the network shim options (an object with hosts and staticResources) need to be passed to the networkShim plugin, the enableNetworkShim setup doesn't accept any arguments anymore.
This has proven to be unreliable
759dc44
to
5a0d574
Compare
# [7.0.0](v6.0.1...v7.0.0) (2021-02-10) ### Code Refactoring * make the network shim cypress-plugin based ([#128](#128)) ([3701dec](3701dec)) ### BREAKING CHANGES * To use the network-shim's functionality the project will need to use the new network shim plugin on top of the existing enableNetworkShim setup. Also, the network shim options (an object with hosts and staticResources) need to be passed to the networkShim plugin, the enableNetworkShim setup doesn't accept any arguments anymore.
🎉 This PR is included in version 7.0.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Before this PR, the networkShim executed some standalone code to clear the fixtures folder. This PR refactors the NetworkShim to be a combination of a setup and a plugin and the standalone code has been removed. The brings several advantages:
/cypress/fixtures/network
but the fixtures destination is actually configurable. Because we can access the fixtures directory path from the cypress config we don't need to make assumptions about this anymore, so this solves a known limitation.As discussed with @amcgee, this plugin based solution still has one known limitation, which is that capturing doesn't work when the run is being done in parallel, because each (parallel) run gets its own plugin instance. The current solution will throw an error if it detects a parallel run in capture mode. I have created an issue that documents the challenges and suggests some possible solutions if we do need to support parallel runs in the future.
Timing-wise I don't think we should this merge this in right now as it will produce a new major version. I think this #115 will also produce breaking changes, so I think we should introduce both of these PRs into master together.
When we bumped from 4 to 5 we included a few codemods. I have not included any codemods in this PR, but if this is what we want to do, I guess I could add a codemode that imports
networkShim
into the plugins index file and callsnetworkShim(on)
. Personally I think that just writing a good changelog and/or migration guide is enough. I'm not a big fan of all this magical codemodding.This PR also includes some not directly related changes: because cypress plugins are NodeJS modules we don't really need to transpile them. Instead we can just use the source code directly. So I've changed some of the code in the plugins modules a little bit and I've removed the build script for the plugins package as well.
BREAKING CHANGE: To use the network-shim's functionality the project will need to use the new network shim plugin on top of the existing enableNetworkShim setup. Also, the network shim options (an object with hosts and staticResources) need to be passed to the networkShim plugin, the enableNetworkShim setup doesn't accept any arguments anymore.