diff --git a/tests/unit/test.program.js b/tests/unit/test.program.js index e159aec3e8..15cb07fcbb 100644 --- a/tests/unit/test.program.js +++ b/tests/unit/test.program.js @@ -1,7 +1,7 @@ import path from 'path'; import fs from 'fs/promises'; -import { describe, it } from 'mocha'; +import { after, before, describe, it } from 'mocha'; import git from 'git-rev-sync'; import * as sinon from 'sinon'; import { assert } from 'chai'; @@ -30,6 +30,23 @@ import { const { spy } = sinon; describe('program.Program', () => { + let originalLcAll; + + before(() => { + // yargs localizes some validation errors based on the environment locale. + // Keep tests that assert on these messages deterministic across systems. + originalLcAll = process.env.LC_ALL; + process.env.LC_ALL = 'en_US.UTF-8'; + }); + + after(() => { + if (originalLcAll === undefined) { + delete process.env.LC_ALL; + } else { + process.env.LC_ALL = originalLcAll; + } + }); + function execProgram(program, options = {}) { const fakeProcess = createFakeProcess(); const absolutePackageDir = path.join(