diff --git a/test/http-api/routes.js b/test/http-api/routes.js index 369930381f..9303f7c43e 100644 --- a/test/http-api/routes.js +++ b/test/http-api/routes.js @@ -58,7 +58,7 @@ describe('HTTP API', () => { this.timeout(50 * 1000) await http.api.stop() - clean(repoTests) + await clean(repoTests) }) describe('## http-api spec tests for custom config', () => { @@ -81,7 +81,7 @@ describe('HTTP API', () => { this.timeout(50 * 1000) await http.api.stop() - clean(repoTests) + await clean(repoTests) }) describe('## http-api spec tests for default config', () => { diff --git a/test/utils/clean.js b/test/utils/clean.js index 13752b594a..248233e641 100644 --- a/test/utils/clean.js +++ b/test/utils/clean.js @@ -1,15 +1,16 @@ 'use strict' const rimraf = require('rimraf') -const fs = require('fs') +const fs = require('fs').promises +const { promisify } = require('util') -module.exports = (dir) => { +module.exports = async dir => { try { - fs.accessSync(dir) + await fs.access(dir) } catch (err) { // Does not exist so all good return } - rimraf.sync(dir) + return promisify(rimraf)(dir) } diff --git a/test/utils/create-repo-nodejs.js b/test/utils/create-repo-nodejs.js index d4a6f87edf..a20fa45e0c 100644 --- a/test/utils/create-repo-nodejs.js +++ b/test/utils/create-repo-nodejs.js @@ -16,10 +16,7 @@ function createTempRepo (repoPath) { series([ // ignore err, might have been closed already (cb) => repo.close(() => cb()), - (cb) => { - clean(repoPath) - cb() - } + (cb) => clean(repoPath).then(cb, cb) ], done) } diff --git a/test/utils/on-and-off.js b/test/utils/on-and-off.js index c9a0b03019..04836af4df 100644 --- a/test/utils/on-and-off.js +++ b/test/utils/on-and-off.js @@ -30,10 +30,9 @@ function off (tests) { return thing.ipfs('init') }) - after(function (done) { + after(function () { this.timeout(20 * 1000) - clean(repoPath) - setImmediate(done) + return clean(repoPath) }) tests(thing)