Title: karma errors when using non-relative path import · Issue #3586 · angular/angular-cli · GitHub
Open Graph Title: karma errors when using non-relative path import · Issue #3586 · angular/angular-cli
X Title: karma errors when using non-relative path import · Issue #3586 · angular/angular-cli
Description: OS? Mac OSX (El Capitan) Versions. angular-cli: 1.0.0-beta.22-1 node: 6.9.1 os: darwin x64 Repro steps. app created using the CLI. Code changes on tsconfig.json, add following lines: "baseUrl": ".", "paths": { "services/*": ["app/shared/...
Open Graph Description: OS? Mac OSX (El Capitan) Versions. angular-cli: 1.0.0-beta.22-1 node: 6.9.1 os: darwin x64 Repro steps. app created using the CLI. Code changes on tsconfig.json, add following lines: "baseUrl": "."...
X Description: OS? Mac OSX (El Capitan) Versions. angular-cli: 1.0.0-beta.22-1 node: 6.9.1 os: darwin x64 Repro steps. app created using the CLI. Code changes on tsconfig.json, add following lines: "baseUrl&...
Opengraph URL: https://github.com/angular/angular-cli/issues/3586
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"karma errors when using non-relative path import","articleBody":"### OS?\r\n> Mac OSX (El Capitan)\r\n\r\n### Versions.\r\n> angular-cli: 1.0.0-beta.22-1\r\nnode: 6.9.1\r\nos: darwin x64\r\n\r\n### Repro steps.\r\n> app created using the CLI. Code changes on tsconfig.json, add following lines:\r\n \"baseUrl\": \".\", \r\n \"paths\": {\r\n \"services/\\*\": [\"app/shared/services/\\*\"]\r\n },\r\n\r\n### The log given by the failure.\r\n> While this configuration is working very well on 'ng serve', the app runs as expected. But **failed on 'ng test'**, it seems like Karma doesn't recognize the non-relative path'. Following is Error msg:\r\n\r\nERROR in ./src/app/cart/cart-summary/cart-summary.component.ts Module not found: Error: Can't resolve 'services/cart' in '/Users/stevezheng/webstorm/mai/src/app/cart/cart-summary'\r\n @ ./src/app/cart/cart-summary/cart-summary.component.ts 12:13-37\r\n @ ./src/app/cart/cart-summary/cart-summary.component.spec.ts\r\n @ ./src \\.spec\\.ts\r\n @ ./src/test.ts\r\nChrome 54.0.2840 (Mac OS X 10.11.6) ERROR\r\n Uncaught Error: Cannot find module \"services/cart\"\r\n at webpack:///Users/stevezheng/webstorm/mai/src/app/cart/cart-summary/cart-summary.component.ts:3:0 \u003c- src/test.ts:53357\r\n\r\n### Other details:\r\nThere's no error when I import \"services/cart\" in my feature.module.ts, but do throw errors when import in xxx.component.ts.\r\nAgain, there's no error for running app but runing test.\r\n\r\nDo I need to config more to make test work or this is a bug?\r\n\r\n### I created a sample for you testing:\r\nhttps://github.com/SteveZheng-BSFT/karma-error-sample\r\nAfter changing to relative path, ng test has no errors.\r\n","author":{"url":"https://github.com/zzs1020","@type":"Person","name":"zzs1020"},"datePublished":"2016-12-16T01:05:44Z","url":"https://github.com/angular/angular-cli/issues/3586"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2364a3bd-6db6-8515-ec62-a3d774322782 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 853E:7A60E:3FE6EB0:51D8F09:6B021B51 |
| html-safe-nonce | ab07839d20838a9b86dab9cb8b7f0f42581748eb8e0990e69639f323c49d1e00 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NTNFOjdBNjBFOjNGRTZFQjA6NTFEOEYwOTo2QjAyMUI1MSIsInZpc2l0b3JfaWQiOiI1OTMyMTY0NzkwNDM1ODQ2OTkzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d067b61a273871d9f7c79af60f585842d4936d1e8b799c7718de322465fe4c94 |
| hovercard-subject-tag | issue:195957296 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/3586/issue_layout |
| twitter:image | https://opengraph.githubassets.com/203f143511249c0ddd1768915dc972953454fd8ba6cf25e388a6808bd683029a/angular/angular-cli/issues/3586 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/203f143511249c0ddd1768915dc972953454fd8ba6cf25e388a6808bd683029a/angular/angular-cli/issues/3586 |
| og:image:alt | OS? Mac OSX (El Capitan) Versions. angular-cli: 1.0.0-beta.22-1 node: 6.9.1 os: darwin x64 Repro steps. app created using the CLI. Code changes on tsconfig.json, add following lines: "baseUrl": "."... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zzs1020 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width