fix(store): be more explicit when checking if Angular is in test mode - #1831
Merged
Conversation
arturovt
requested review from
Carniatto,
joaqcid,
kuncevic,
markwhitfeld,
poloagustin and
splincode
as code owners
March 15, 2022 18:29
arturovt
force-pushed
the
fix/is-test-mode
branch
from
March 15, 2022 18:31
1c12b95 to
ebbe07d
Compare
splincode
reviewed
Mar 16, 2022
splincode
approved these changes
Mar 16, 2022
Comment on lines
10
to
13
| function resetMemoization() { | ||
| const fn = <any>isAngularInTestMode; | ||
| // Reset the memoization | ||
| fn && fn.reset && fn.reset(); |
Member
There was a problem hiding this comment.
I don't think it is necessary to memoise this anymore because the checks are so simple!
We could remove the memoisation from the lib export and remove this testing code.
| expect(result).toEqual(true); | ||
| it('should return true if `__karma__` is available', () => { | ||
| // Arrange & act & assert | ||
| const __karma__ = ɵglobal.__karma__; |
Member
There was a problem hiding this comment.
We could have a test helper (like the freshPlatform one you created) that wraps the test execution with a try..finally and stores and restores the values on ɵglobal (or deletes them again if they weren't there to begin with).
eg:
it('should return true if `__karma__` is available', isolateGlobalTestProps(() => {
Member
Author
There was a problem hiding this comment.
I'd like to keep these tests simple for now. We could've thought about the isolateGlobalTestProps implementation in the future.
arturovt
force-pushed
the
fix/is-test-mode
branch
from
March 16, 2022 19:51
20d4cf9 to
f43d3a0
Compare
Member
Author
|
Mark, I’ve merged it, just wanna test it in our app. I can make further changes in another PR if needed. |
crapStone
pushed a commit
to Calciumdibromid/CaBr2
that referenced
this pull request
Jun 17, 2022
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@ngxs/form-plugin](https://github.com/ngxs/store) | dependencies | patch | [`3.7.3` -> `3.7.4`](https://renovatebot.com/diffs/npm/@ngxs%2fform-plugin/3.7.3/3.7.4) | | [@ngxs/storage-plugin](https://github.com/ngxs/store) | dependencies | patch | [`3.7.3` -> `3.7.4`](https://renovatebot.com/diffs/npm/@ngxs%2fstorage-plugin/3.7.3/3.7.4) | | [@ngxs/store](https://github.com/ngxs/store) | dependencies | patch | [`3.7.3` -> `3.7.4`](https://renovatebot.com/diffs/npm/@ngxs%2fstore/3.7.3/3.7.4) | --- ### Release Notes <details> <summary>ngxs/store</summary> ### [`v3.7.4`](https://github.com/ngxs/store/blob/HEAD/CHANGELOG.md#​374-2022-06-09) [Compare Source](ngxs/store@v3.7.3...v3.7.4) - Build: include support for Angular 14 [#​1850](ngxs/store#1850) - Fix: Do not re-use the global `Store` instance between different apps [#​1740](ngxs/store#1740) and [#​1804](ngxs/store#1804) - Fix: Handle mixed async scenarios for action handlers [#​1762](ngxs/store#1762) - Fix: An action with cancelUncompleted enabled should unsubscribe before the next action handler is called [#​1763](ngxs/store#1763) - Fix: Do not run `Promise.then` within synchronous tests when decorating factory [#​1753](ngxs/store#1753) - Fix: Provide `NoopNgxsExecutionStrategy` explicitly when the zone is nooped [#​1819](ngxs/store#1819) - Fix: Complete the state stream once the root view is removed [#​1830](ngxs/store#1830) - Fix: Be more explicit when checking if Angular is in test mode [#​1831](ngxs/store#1831), [#​1832](ngxs/store#1832) - Fix: Devtools Plugin - Do not connect to devtools when the plugin is disabled [#​1761](ngxs/store#1761) - Fix: Router Plugin - Cleanup subscriptions when the root view is destroyed [#​1754](ngxs/store#1754) - Fix: WebSocket Plugin - Cleanup subscriptions and close the connection when the root view is destroyed [#​1755](ngxs/store#1755) - Fix: Storage Plugin - Only restore state if key matches `addedStates` [#​1746](ngxs/store#1746) - Fix: Forms Plugin - Do not destructure primitive types [#​1845](ngxs/store#1845) - Performance: Tree-shake errors and warnings [#​1732](ngxs/store#1732) - Performance: Tree-shake `ConfigValidator`, `HostEnvironment` and `isAngularInTestMode` [#​1741](ngxs/store#1741) - Performance: Tree-shake `SelectFactory` [#​1744](ngxs/store#1744) - Performance: Tree-shake `deepFreeze` [#​1819](ngxs/store#1819) - Performance: Run change detection once for all selectors when asynchronous action has been completed [#​1828](ngxs/store#1828) - Performance: Router Plugin - Tree-shake `isAngularInTestMode()` [#​1738](ngxs/store#1738) - Performance: Tree-shake `isAngularInTestMode()` [#​1739](ngxs/store#1739) - Performance: Storage Plugin - Tree-shake `console.*` calls and expand error messages [#​1727](ngxs/store#1727) - CI: Bundlesize checks should run reliably [#​1812](ngxs/store#1812) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). Co-authored-by: cabr2-bot <cabr2.help@gmail.com> Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1401 Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org> Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@markwhitfeld I've noticed that this function doesn't work in ESP app because there's no
MockNgModuleResolveranymore (the@angular/compiler/testing) just doesn't export anything now. TheeMockNgModuleResolverwas available before the VE support has been removed.We couldn't see that in NGXS repository since our packages are version 9.