Skip to content

Unable to load locale data in unit tests when using Angular 5 #1184

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

Closed
YvesCandel opened this issue Feb 2, 2018 · 1 comment
Closed

Unable to load locale data in unit tests when using Angular 5 #1184

YvesCandel opened this issue Feb 2, 2018 · 1 comment

Comments

@YvesCandel
Copy link

Please, provide the details below:

Did you verify this is a real problem by searching the NativeScript Forum and the other open issues in this repo?

Yes.

Tell us about the problem

When using Angular 5, any localization in unit tests seems to fail.

Which platform(s) does your issue occur on?

Both

Please provide the following version numbers that your issue occurs with:

  • CLI: 3.4.1
  • Cross-platform modules: 3.4.0
  • Runtime(s): 3.4.1
  • Plugin(s): -

Please tell us how to recreate the issue in as much detail as possible.

I have created a demo app at https://github.com/YvesCandel/tns-34-ng-52-locales

The issue can be reproduced using:

git clone https://github.com/YvesCandel/tns-34-ng-52-locales.git
cd tns-34-ng-52-locales
npm i
tns test ios --justlaunch --emulator

All the tests will fail because the locale data cannot be found:

    PercentPipe
      transform
        ✗ should return correct value for numbers
	TypeError: undefined is not an object (evaluating 'data[0 /* LocaleId */]') in file:///app/tns_modules/@angular/common/bundles/common.umd.js (line 1020)
	registerLocaleData@file:///app/tns_modules/@angular/common/bundles/common.umd.js:1020:24
	file:///app/tests/decimal.pipe.spec.js:12:40
	attempt
	run
	execute
	queueRunnerFactory
	fn
	attempt
	run
	execute
	queueRunnerFactory
	execute
	execute
	runTests@file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:216:23
	file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:187:101
	invoke@file:///app/tns_modules/tns-core-modules/timer/timer.js:54:53
	tick@file:///app/tns_modules/tns-core-modules/timer/timer.js:19:26
	UIApplicationMain@[native code]
	start@file:///app/tns_modules/tns-core-modules/application/application.js:235:26
	anonymous@file:///app/tns_modules/nativescript-unit-test-runner/app.js:3:18
	evaluate@[native code]
	moduleEvaluation@[native code]
	[native code]
	promiseReactionJob@[native code]

	Error: Missing locale data for the locale "fr". in file:///app/tns_modules/@angular/common/bundles/common.umd.js (line 1542)
	findLocaleData@file:///app/tns_modules/@angular/common/bundles/common.umd.js:1542:20
	getLocaleNumberFormat@file:///app/tns_modules/@angular/common/bundles/common.umd.js:1385:47
	formatNumber$1@file:///app/tns_modules/@angular/common/bundles/common.umd.js:5000:56
	transform@file:///app/tns_modules/@angular/common/bundles/common.umd.js:6206:32
	file:///app/tests/decimal.pipe.spec.js:65:42
	attempt
	run
	execute
	queueRunnerFactory
	execute
	fn
	attempt
	run
	execute
	queueRunnerFactory
	fn
	attempt
	run
	execute
	queueRunnerFactory
	fn
	attempt
	run
	runNext
	onComplete
	invoke@file:///app/tns_modules/tns-core-modules/timer/timer.js:54:53
	tick@file:///app/tns_modules/tns-core-modules/timer/timer.js:19:26
	UIApplicationMain@[native code]
	start@file:///app/tns_modules/tns-core-modules/application/application.js:235:26
	anonymous@file:///app/tns_modules/nativescript-unit-test-runner/app.js:3:18
	evaluate@[native code]
	moduleEvaluation@[native code]
	[native code]
	promiseReactionJob@[native code]

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

The code can be found in the app/tests folder. The unit test is copied from the main Angular project. (https://github.com/angular/angular/blob/master/packages/common/test/pipes/number_pipe_spec.ts)

@NickIliev
Copy link

NickIliev commented Feb 2, 2018

closing as related to #1133 - please use the linked issue for updates related to supporting the Angular-5 localization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants