Merge pull request #2269 from tailwindlabs/fix-promise-finally

use explicit .then and .catch instead of .finally for node 8.x
This commit is contained in:
Robin Malfait 2020-08-28 15:36:45 +02:00 committed by GitHub
commit 681e4d8f38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,9 +8,13 @@ function suppressConsoleLogs(cb, type = 'warn') {
return () => {
const spy = jest.spyOn(global.console, type).mockImplementation(jest.fn())
return new Promise((resolve, reject) => {
const promise = new Promise((resolve, reject) => {
Promise.resolve(cb()).then(resolve, reject)
}).finally(() => spy.mockRestore())
})
promise.then(spy.mockRestor, spy.mockRestore)
return promise
}
}