I have a basic AngularJS2 project created with angular-cli. I start with the freshly generated project. In app.component.ts
, I store a date:
theDate = new Date();
I display it using a date pipe:
{{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
The failing test is:
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'),
...
] ...
Remarks:
- angular-cli "1.0.0-beta.16"
- I've switched to
PhantomJS
for convenience but the same occurs withChrome
. - I did perform
npm install --save
to install dependencies.
In order to make things easier to the reader, the project is stored here.
What is the missing piece? Thank you.