René's URL Explorer Experiment


Title: Schematics: Unit testing a rule that uses mergeWith/apply fails due to missing context · Issue #17205 · angular/angular-cli · GitHub

Open Graph Title: Schematics: Unit testing a rule that uses mergeWith/apply fails due to missing context · Issue #17205 · angular/angular-cli

X Title: Schematics: Unit testing a rule that uses mergeWith/apply fails due to missing context · Issue #17205 · angular/angular-cli

Description: Addendum In creating the test case I've realised that I'm not passing a partialContext to callRule, so it is definitely missing context, however, it is not at all clear what context is necessary for mergeWith to succeed and the error doe...

Open Graph Description: Addendum In creating the test case I've realised that I'm not passing a partialContext to callRule, so it is definitely missing context, however, it is not at all clear what context is necessary fo...

X Description: Addendum In creating the test case I've realised that I'm not passing a partialContext to callRule, so it is definitely missing context, however, it is not at all clear what context is nece...

Opengraph URL: https://github.com/angular/angular-cli/issues/17205

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Schematics: Unit testing a rule that uses mergeWith/apply fails due to missing context","articleBody":"## Addendum\r\n\r\nIn creating the test case I've realised that I'm not passing a `partialContext` to `callRule`, so it is definitely missing context, however, it is not at all clear _what_ context is necessary for `mergeWith` to succeed and the error does not indicate that context is actually missing.\r\n\r\nHappy for this to be marked as a question instead. Guidance on _how_ to provide the context and _what_ context to provide would be amazingly useful.\r\n\r\n# 🐞 Bug report\r\n\r\n### Description\r\n\r\nUsing `callRule` to unit test rules within a schematic fails when it comes to rules which return `mergeWith`\r\n\r\n## 🔬 Minimal Reproduction\r\n\r\nSee: https://github.com/jdpearce/schematics-apply-problem\r\n\r\nGiven a rule which applies template files to the tree, this unit test will fail with `TypeError: Cannot read property 'path' of undefined`:\r\n\r\n```ts\r\ndescribe('applyTemplateFiles Rule', () =\u003e {\r\n  let tree: UnitTestTree;\r\n\r\n  beforeEach(async () =\u003e {\r\n    tree = new UnitTestTree(Tree.empty());\r\n  });\r\n\r\n  it('should apply the files to the tree', async () =\u003e {\r\n    const schema = {};\r\n\r\n    tree = (await callRule(applyTemplateFiles(schema), tree)) as UnitTestTree;\r\n\r\n    expect(tree.files).toEqual(jasmine.arrayContaining(['/libs/destination/test.txt']));\r\n  });\r\n});\r\n```\r\n\r\n## 🔥 Exception or Error\r\n\r\n```bash\r\nFailures:\r\n1) applyTemplateFiles Rule should apply the files to the tree\r\n  Message:\r\n    TypeError: Cannot read property 'path' of undefined\r\n  Stack:\r\n        at \u003cJasmine\u003e\r\n        at ./apply-problem/node_modules/@angular-devkit/schematics/tools/file-system-engine-host-base.js:216:96\r\n        at ./tmp/apply-problem/node_modules/@angular-devkit/schematics/src/rules/url.js:13:73\r\n        at Object.callSource (./tmp/apply-problem/node_modules/@angular-devkit/schematics/src/rules/call.js:55:20)\r\n        at ./tmp/apply-problem/node_modules/@angular-devkit/schematics/src/rules/base.js:45:60\r\n        at Object.callSource (./tmp/apply-problem/node_modules/@angular-devkit/schematics/src/rules/call.js:55:20)\r\n        at ./tmp/apply-problem/node_modules/@angular-devkit/schematics/src/rules/base.js:53:23\r\n        at MergeMapSubscriber.project (./tmp/apply-problem/node_modules/@angular-devkit/schematics/src/rules/call.js:74:24)\r\n        at MergeMapSubscriber._tryNext (./tmp/apply-problem/node_modules/rxjs/internal/operators/mergeMap.js:69:27)\r\n        at MergeMapSubscriber._next (./tmp/apply-problem/node_modules/rxjs/internal/operators/mergeMap.js:59:18)\r\n        at MergeMapSubscriber.Subscriber.next (./tmp/apply-problem/node_modules/rxjs/internal/Subscriber.js:66:18)\r\n\r\n2 specs, 1 failure\r\n```\r\n\r\n## 🌍 Your Environment\r\n\r\n    \"@angular-devkit/core\": \"^9.0.6\",\r\n    \"@angular-devkit/schematics\": \"^9.0.6\",\r\n    \"@types/jasmine\": \"^3.3.9\",\r\n    \"@types/node\": \"^8.0.31\",\r\n    \"jasmine\": \"^3.3.1\",\r\n    \"typescript\": \"~3.5.3\"\r\n","author":{"url":"https://github.com/catfireparty","@type":"Person","name":"catfireparty"},"datePublished":"2020-03-12T12:00:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/17205/angular-cli/issues/17205"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:4ead09aa-7f37-72ad-1214-2057e5bfe3da
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD502:3CDF6F:1A7DA0E:243FF2B:6964C027
html-safe-nonce3aa945518585b8273bc88d9838a54fbf00b18e67f656ab0257e8cef26c26a8b9
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENTAyOjNDREY2RjoxQTdEQTBFOjI0M0ZGMkI6Njk2NEMwMjciLCJ2aXNpdG9yX2lkIjoiMjM0OTUzNjIxMTUwMDMxODc2MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac3e3dfae85b8a86c93a7f34290e3f40e9515d30eee03ced14370ebe251280e5b3
hovercard-subject-tagissue:579889600
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/17205/issue_layout
twitter:imagehttps://opengraph.githubassets.com/50439b2ce8009e99f0492f7dbdce7d9576bb9ab9d96e39bb8440eef0a2a60676/angular/angular-cli/issues/17205
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/50439b2ce8009e99f0492f7dbdce7d9576bb9ab9d96e39bb8440eef0a2a60676/angular/angular-cli/issues/17205
og:image:altAddendum In creating the test case I've realised that I'm not passing a partialContext to callRule, so it is definitely missing context, however, it is not at all clear what context is necessary fo...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamecatfireparty
hostnamegithub.com
expected-hostnamegithub.com
None21df671ce2c9f1a16940ccbd3af6cb4f3f12a856929ca7eb1b4aea8e384ea442
turbo-cache-controlno-preview
go-importgithub.com/angular/angular-cli git https://github.com/angular/angular-cli.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id36891867
octolytics-dimension-repository_nwoangular/angular-cli
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id36891867
octolytics-dimension-repository_network_root_nwoangular/angular-cli
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release5707c685ac172d50a0bdd7533dde4f8aabcf8eef
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/angular/angular-cli/issues/17205#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular-cli%2Fissues%2F17205
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular-cli%2Fissues%2F17205
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular-cli
Reloadhttps://github.com/angular/angular-cli/issues/17205
Reloadhttps://github.com/angular/angular-cli/issues/17205
Reloadhttps://github.com/angular/angular-cli/issues/17205
angular https://github.com/angular
angular-clihttps://github.com/angular/angular-cli
Notifications https://github.com/login?return_to=%2Fangular%2Fangular-cli
Fork 11.9k https://github.com/login?return_to=%2Fangular%2Fangular-cli
Star 27k https://github.com/login?return_to=%2Fangular%2Fangular-cli
Code https://github.com/angular/angular-cli
Issues 264 https://github.com/angular/angular-cli/issues
Pull requests 24 https://github.com/angular/angular-cli/pulls
Actions https://github.com/angular/angular-cli/actions
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/angular/angular-cli/security
Please reload this pagehttps://github.com/angular/angular-cli/issues/17205
Insights https://github.com/angular/angular-cli/pulse
Code https://github.com/angular/angular-cli
Issues https://github.com/angular/angular-cli/issues
Pull requests https://github.com/angular/angular-cli/pulls
Actions https://github.com/angular/angular-cli/actions
Security https://github.com/angular/angular-cli/security
Insights https://github.com/angular/angular-cli/pulse
New issuehttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/17205
New issuehttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/17205
Schematics: Unit testing a rule that uses mergeWith/apply fails due to missing contexthttps://github.com/angular/angular-cli/issues/17205#top
area: @angular-devkit/schematicshttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular-devkit%2Fschematics%22
freq1: lowOnly reported by a handful of users who observe it rarelyhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22freq1%3A%20low%22
severity3: brokenhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22severity3%3A%20broken%22
type: bug/fixhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%2Ffix%22
Backloghttps://github.com/angular/angular-cli/milestone/12
https://github.com/catfireparty
https://github.com/catfireparty
catfirepartyhttps://github.com/catfireparty
on Mar 12, 2020https://github.com/angular/angular-cli/issues/17205#issue-579889600
https://github.com/jdpearce/schematics-apply-problemhttps://github.com/jdpearce/schematics-apply-problem
area: @angular-devkit/schematicshttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular-devkit%2Fschematics%22
freq1: lowOnly reported by a handful of users who observe it rarelyhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22freq1%3A%20low%22
severity3: brokenhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22severity3%3A%20broken%22
type: bug/fixhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%2Ffix%22
BacklogNo due datehttps://github.com/angular/angular-cli/milestone/12
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.