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/services/*"]
},
The log given by the failure.
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:
ERROR 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'
@ ./src/app/cart/cart-summary/cart-summary.component.ts 12:13-37
@ ./src/app/cart/cart-summary/cart-summary.component.spec.ts
@ ./src .spec.ts
@ ./src/test.ts
Chrome 54.0.2840 (Mac OS X 10.11.6) ERROR
Uncaught Error: Cannot find module "services/cart"
at webpack:///Users/stevezheng/webstorm/mai/src/app/cart/cart-summary/cart-summary.component.ts:3:0 <- src/test.ts:53357
Other details:
There's no error when I import "services/cart" in my feature.module.ts, but do throw errors when import in xxx.component.ts.
Again, there's no error for running app but runing test.
Do I need to config more to make test work or this is a bug?
I created a sample for you testing:
https://github.com/SteveZheng-BSFT/karma-error-sample
After changing to relative path, ng test has no errors.