Describe your issue:
There's an issue with jest where it does not properly pass along the process.env value when calling spawn. This is because jest sandboxes and isolates a copy of process.env which means that any changes to process.env made inside of a test setup script, for example, will not be reflected in subprocess environment. One simple way to resolve this is to just explicitly pass process.env to the spawn call.
Relevant Jest issue here.
The code of the library usage:
import { prepareEnvironment } from '@gmrchk/cli-testing-library';
process.env.COOL_ENV_VAR = 'foo';
it('program', async () => {
const { cleanup, exec path } = await prepareEnvironment();
const { stdout } = await exec('printenv');
console.log(stdout); // COOL_ENV_VAR is not there
await cleanup();
});
Before creating this issue, did you think of...:
Describe your issue:
There's an issue with
jestwhere it does not properly pass along theprocess.envvalue when callingspawn. This is because jest sandboxes and isolates a copy ofprocess.envwhich means that any changes toprocess.envmade inside of a test setup script, for example, will not be reflected in subprocess environment. One simple way to resolve this is to just explicitly passprocess.envto thespawncall.Relevant Jest issue here.
The code of the library usage:
Before creating this issue, did you think of...: