diff --git a/test.js b/test.js index cbc2cd5a22..6c46a7dc99 100644 --- a/test.js +++ b/test.js @@ -65,15 +65,15 @@ test('stdout/stderr/all are undefined if ignored in sync mode', t => { t.is(all, undefined); }); +const WRONG_COMMAND = process.platform === 'win32' ? + '\'wrong\' is not recognized as an internal or external command,\r\noperable program or batch file.' : + ''; + test('stdout/stderr/all on process errors', async t => { const {stdout, stderr, all} = await t.throwsAsync(execa('wrong command')); t.is(stdout, ''); - t.is(stderr, process.platform === 'win32' ? - '\'wrong\' is not recognized as an internal or external command,\r\noperable program or batch file.' : - ''); - t.is(all, process.platform === 'win32' ? - '\'wrong\' is not recognized as an internal or external command,\r\noperable program or batch file.' : - ''); + t.is(stderr, WRONG_COMMAND); + t.is(all, WRONG_COMMAND); }); test('stdout/stderr/all on process errors, in sync mode', t => { @@ -81,9 +81,7 @@ test('stdout/stderr/all on process errors, in sync mode', t => { execa.sync('wrong command'); }); t.is(stdout, ''); - t.is(stderr, process.platform === 'win32' ? - '\'wrong\' is not recognized as an internal or external command,\r\noperable program or batch file.' : - ''); + t.is(stderr, WRONG_COMMAND); t.is(all, undefined); });