I have an AngularJS2 base project created using angular-cli. I start with the project just created. In app.component.tsI save the date:
theDate = new Date();
I show it using date:
{{theDate | date}}
The date is correctly displayed and formatted as expected. But if I run ng test, I get the following error:
Failed: Error in ./AppComponent class AppComponent - inline template:4:3 caused by: No locale data has been provided for this object yet.
g@node_modules/karma-intl-shim/lib/shim.js:11:1866
F@node_modules/karma-intl-shim/lib/shim.js:11:8835
k@node_modules/karma-intl-shim/lib/shim.js:11:8335
Test with an error:
it('should render title in a h1 tag', async(() => {
let fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
let compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('app works!');
}));
package.json:
"karma-intl-shim": "^1.0.3"
karma.conf:
module.exports = function (config) {
config.set({
...
frameworks: ['jasmine', 'angular-cli', 'intl-shim'],
plugins: [
require('karma-intl-shim'),
...
] ...
Notes:
- angular-cli "1.0.0-beta.16"
- I switched to
PhantomJSfor convenience, but the same thing happens with Chrome. - I performed
npm install --saveto install the dependencies.
For ease of reading, the project is saved here .
What is the missing part? Thank.