Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix problems with third-party Promise (#427)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
- Loading branch information
1 parent
e222526
commit 96ad152
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import path from 'path'; | ||
import test from 'ava'; | ||
|
||
process.env.PATH = path.join(__dirname, 'fixtures') + path.delimiter + process.env.PATH; | ||
|
||
// Can't use `test.before`, because `ava` needs `Promise`. | ||
// Can't use `import(…)` either, because `execa` is not an ES Module. | ||
const nativePromise = Promise; | ||
global.Promise = class BrokenPromise { | ||
then() { | ||
throw new Error('error'); | ||
} | ||
}; | ||
const execa = require('..'); | ||
global.Promise = nativePromise; | ||
|
||
test('should work with third-party Promise', async t => { | ||
const {stdout} = await execa('noop', ['foo']); | ||
t.is(stdout, 'foo'); | ||
}); |