Skip to content
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

meteor test: Installed but msgfmt.init('en') etc was never called. #242

Closed
dasdeck opened this issue Jul 29, 2016 · 8 comments
Closed

meteor test: Installed but msgfmt.init('en') etc was never called. #242

dasdeck opened this issue Jul 29, 2016 · 8 comments

Comments

@dasdeck
Copy link

dasdeck commented Jul 29, 2016

Hi!
I'm using latest v2 release and all works good and well, but when I try to start meteor with:
Meteor is 1.4.

meteor test --driver-package practicalmeteor:mocha --port 3005

I get:

Error: [msgfmt] Installed but msgfmt.init('en') etc was never called.

I'm happy to help debugging the problem, though I'm not sure where to start in this case.
Any ideas?

This seems to be a related Issue:

tomitrescak/meteor-boilerplate-typescript#1

Cheers!

JM

@dasdeck dasdeck changed the title When testing: Installed but msgfmt.init('en') etc was never called. meteor test: Installed but msgfmt.init('en') etc was never called. Jul 29, 2016
@n1c01a5
Copy link

n1c01a5 commented Aug 15, 2016

Have you added msgfmt.init('en') in lib/config.js ?

@dasdeck
Copy link
Author

dasdeck commented Aug 16, 2016

I added it in varous places to check whether it might make a difference.
You mean liken in $METEOR_ROOT/lib/config.js ?
I supposes config is just another js file?

@DSpeichert
Copy link
Collaborator

@dasdeck This call should execute at least before any other call to mf(). There isn't any defined place where it has to be, so lib/config.js is a good one because it runs on both client and server.

@dasdeck
Copy link
Author

dasdeck commented Aug 16, 2016

Yea, thats what I thought!
Mind you, the app runs without problems, the msgfmt.init('en') is called successfully in a "/lib/startup.js".
Still not working in "isTest" mode though.
So this seems not to be the reason. :/
Thanks for the help though!

@Kombustor
Copy link

Quite some time went by, but I'm still getting this error. I placed
msgfmt.init('en');
into /lib/msgfmt-config.js, and everything works fine.

But when running unit-tests with meteor test it still prints out the error
Installed but msgfmt.init('en') etc was never called.

This causes all my tests to fail, what can I possibly do to avoid the issue?

@thePunderWoman
Copy link

+1 I'm seeing this exact issue too. We definitely have the msgfmt.init('en') being called, and the app runs fine, but meteor test fail entirely.

@gadicc
Copy link
Owner

gadicc commented May 2, 2017

TL;DR

In short, to test successfully with msgfmt, use meteor test --full-app.

Explanation:

Hi all, sorry that I'm not so active here atm. I do feel bad that this issue was first opened 10 months ago :/

To partially quote from Meteor Guide: Testing:

meteor test:

  • Doesn’t eagerly load any of our application code as Meteor normally would.

Additionally, Meteor offers a “full application” test mode. You can run this with meteor test --full-app.

  • It does eagerly load our application code as Meteor normally would.

So if you're calling msgfinit.init('en') in say, lib/startup.js -- this file is only loaded in "full application mode". It's important to understand the difference between these two test modes though, as you may run into similar issues in the future, without a clear warning that something is wrong like msgfmt is doing.

It might be nice to have a special test mode built into msgfmt for unit tests / regular test mode. Since msgfmt won't be fully loaded, it won't know what the native language is nor will it load any locales. So unit testing for translation is out (obviously in the app context that's an integration test and not a unit test), but probably all we want for app unit tests is for things not to break. Returning the inline native text (and dealing with variables) should be enough. Unfortunately this isn't something I have time to work one, but I'll happily accept a PR for this.

In any event, everything works as expected with meteor test --full-app.

@dasdeck
Copy link
Author

dasdeck commented Oct 16, 2017

sbeen a long time, just doing some cleanup and closing this.
Cheers!
JM

@dasdeck dasdeck closed this as completed Oct 16, 2017
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

6 participants