Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ module.exports = function(grunt) {
// Default task.
grunt.registerTask('default', ['browserify']);

grunt.registerTask('set-test-env', function() {
process.env.NODE_ENV = 'test';
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not work when running the tests manually via mocha. I am proposing to use env-test module instead and configure the environment in test/mocha.opts.


grunt.registerTask('test', [
'eslint',
process.env.JENKINS_HOME ? 'mochaTest:unit-xml' : 'mochaTest:unit',
Expand All @@ -242,5 +246,5 @@ module.exports = function(grunt) {
]);

// alias for sl-ci-run and `npm test`
grunt.registerTask('mocha-and-karma', ['test']);
grunt.registerTask('mocha-and-karma', ['set-test-env', 'test']);
};
7 changes: 6 additions & 1 deletion lib/globalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@
var path = require('path');
var SG = require('strong-globalize');

if (process.env.NODE_ENV === 'test') {
module.exports = SG({language: 'en'});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Setogit I am wondering, what environment variables should we change in our tests in order to force strong-globalize to use en language when running the test suite? I'd like to avoid this custom SG initialization used by our tests only.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To set the default language, you can use two environment variables:
STRONGLOOP_GLOBALIZE_APP_LANGUAGE, or the OS-level local environment variable, e.g. LANG.

} else {
module.exports = SG();
}

SG.SetRootDir(path.join(__dirname, '..'), {autonomousMsgLoading: 'all'});
module.exports = SG();