Skip to content

Commit

Permalink
feat(build): add --lang flag to set LANG env var for lb-mocha
Browse files Browse the repository at this point in the history
This allow tests to be executed with a given language.
  • Loading branch information
raymondfeng committed Feb 26, 2020
1 parent 501bd78 commit a78bb84
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/build/bin/run-mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ function run(argv, options) {
mochaOpts.splice(allowConsoleLogsIx, 1);
}

// Allow `--lang en_US.UTF-8`
const lang = mochaOpts.indexOf('--lang');
if (lang !== -1) {
process.env.LANG = mochaOpts[lang + 1];
mochaOpts.splice(lang, 2);
}

const args = [...mochaOpts];

return utils.runCLI('mocha/bin/mocha', args, options);
Expand Down
12 changes: 12 additions & 0 deletions packages/build/test/integration/scripts.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,18 @@ describe('mocha', function() {
);
});

it('honors --lang option', () => {
const LANG = process.env.LANG;
const run = require('../../bin/run-mocha');
const command = run(
['node', 'bin/run-mocha', '--lang', 'fr', '"dist/__tests__"'],
true,
);
assert.equal(process.env.LANG, 'fr');
assert(command.indexOf('--lang fr') === -1, '--lang fr should be removed');
process.env.LANG = LANG;
});

it('loads .mocharc.json specific project file', () => {
const run = require('../../bin/run-mocha');
const buitInMochaOptsPath = path.join(
Expand Down

0 comments on commit a78bb84

Please sign in to comment.