Unit test Karma/jasmine: error while loading json language files
See original GitHub issueI’m submitting a … (check one with “x”)
[x ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request
Current behavior while running the unit tests with angular-cli ( command ng-test) , my tests fail because the loader of Karma doesn t handle correcterly the /i18n/*.json files. The following exception is returned:
Uncaught SyntaxError: Unexpected token : at src/assets/i18n/en.json
Expected/desired behavior This behavior occurs only when I try to run unit tests. Otherwise my application works perfectly fine. ng2-translate should be compatible with karma/jasmine and we shouldn t get exception while loading *json files
Reproduction of the problem If the current behavior is a bug or you can illustrate your feature request better with an example, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:btpW3l0jr5beJVjohy1Q).
run a karma unit test on a component containing the translate filter
What is the expected behavior?
What is the motivation / use case for changing the behavior? I cannot test anymore my components which use ng translate
Please tell us about your environment:
-
ng2-translate version: 3.1.3
-
Angular version: 2.1.0
-
Browser: [Chrome]
-
Language: [TypeScript 2.0]
Issue Analytics
- State:
- Created 7 years ago
- Comments:9
Top GitHub Comments
Hello, can someone provide an example translate application with unit test (i.e., test the translated values from json).
That’s true. I should add a test with that and it could serve as a documentation.