-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using ng5 new locale feature #92
Comments
Update you Jest config to transform {
"transformIgnorePatterns": [
"node_modules/(?!@ngrx|@angular/common)"
]
}
|
Hi, just tried a few different combinations in my package.json, but none of them is working.
But the error still remains. Found a comment in the JEST issue tracker describing that scoped packages could be a problem. |
It's rather unlikely it has anything to do with scoped packages (you can see it works for {
"transformIgnorePatterns": [
"node_modules/(?!@angular)"
]
} |
And run jest with |
still the same error, here is my full jest configuration in package.json
|
Got it temporary working transpiling the file |
You can also try clearing the cache: jestjs/jest#3705 (comment) and see if that helps |
clearing cache does not help anyway... Transpiling by myself is atm the only way to get the translation working in the tests... here is my working example setupJest.ts import { registerLocaleData } from '@angular/common';
// import localeDe from '@angular/common/locales/de'
import 'jest-preset-angular';
// transpiled localeDe from above (typescript playground)
registerLocaleData([
'de',
[
['vm.', 'nm.'],
['vorm.', 'nachm.'],
],
[
['vorm.', 'nachm.'],
,
],
[
['S', 'M', 'D', 'M', 'D', 'F', 'S'], ['So.', 'Mo.', 'Di.', 'Mi.', 'Do.', 'Fr.', 'Sa.'],
['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'],
['So.', 'Mo.', 'Di.', 'Mi.', 'Do.', 'Fr.', 'Sa.']
],
[
['S', 'M', 'D', 'M', 'D', 'F', 'S'], ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'],
['So.', 'Mo.', 'Di.', 'Mi.', 'Do.', 'Fr.', 'Sa.']
],
[
['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
['Jan.', 'Feb.', 'März', 'Apr.', 'Mai', 'Juni', 'Juli', 'Aug.', 'Sep.', 'Okt.', 'Nov.', 'Dez.'],
[
'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober',
'November', 'Dezember'
]
],
[
['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
['Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'],
[
'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober',
'November', 'Dezember'
]
],
[
['v. Chr.', 'n. Chr.'],
,
],
1, [6, 0], ['dd.MM.yy', 'dd.MM.y', 'd. MMMM y', 'EEEE, d. MMMM y'],
['HH:mm', 'HH:mm:ss', 'HH:mm:ss z', 'HH:mm:ss zzzz'],
[
'{1}, {0}',
,
'{1} \'um\' {0}',
],
[',', '.', ';', '%', '+', '-', 'E', '·', '‰', '∞', 'NaN', ':'],
['#,##0.###', '#,##0 %', '#,##0.00 ¤', '#E0'], '€', 'Euro',
function (n) {
var i = Math.floor(Math.abs(n)), v = n.toString().replace(/^[^.]*\.?/, '').length;
if (i === 1 && v === 0)
return 1;
return 5;
}
]); localeDEComponent.spec.ts providers: [
{provide: LOCALE_ID, useValue: 'de'},
] |
I have the same problems - even if I transpile manually as @marcojahn said 2 tests are still failing UPDATE: I found a solution:
|
I wonder if we should add this by default – compiling JS files with Babel instead of TS? |
@thymikee can we reopen this issue? I just encountered it and none of the suggested solutions work for me. |
Actually Brototype's solution with babel works for me |
I think his solution is similar to README as well. So I think we don't need to modify README for this situation 😀 |
I've tried to setup Angular5s new locale System to have these features within my tests.
What I have done is (setupJest.ts)
But got the following errors
Any recommendations on how to set it up ?
The text was updated successfully, but these errors were encountered: