diff --git a/test/defaultbrowsercontext.jest.js b/test/defaultbrowsercontext.jest.js index c8d61f25ff461..9ec51573f8a0f 100644 --- a/test/defaultbrowsercontext.jest.js +++ b/test/defaultbrowsercontext.jest.js @@ -19,10 +19,8 @@ const fs = require('fs'); const path = require('path'); const utils = require('./utils'); const os = require('os'); -const {promisify} = require('util'); -const mkdtempAsync = promisify(fs.mkdtemp); -const {makeUserDataDir, removeUserDataDir} = utils; +const {mkdtempAsync, makeUserDataDir, removeUserDataDir} = utils; const {FFOX, MAC, CHROMIUM, WEBKIT, WIN, USES_HOOKS} = testOptions; registerFixture('userDataDir', async ({}, test) => { diff --git a/test/download.jest.js b/test/download.jest.js index 6289ebfabb790..6934fbc3ff910 100644 --- a/test/download.jest.js +++ b/test/download.jest.js @@ -18,9 +18,7 @@ const fs = require('fs'); const path = require('path'); const util = require('util'); const os = require('os'); -const removeFolder = require('rimraf'); -const mkdtempAsync = util.promisify(fs.mkdtemp); -const removeFolderAsync = util.promisify(removeFolder); +const {mkdtempAsync, removeFolderAsync} = require('./utils'); const {FFOX, CHROMIUM, WEBKIT, HEADLESS} = testOptions; diff --git a/test/downloadsPath.jest.js b/test/downloadsPath.jest.js index 1e8fa2ba1797f..5807c565d4208 100644 --- a/test/downloadsPath.jest.js +++ b/test/downloadsPath.jest.js @@ -16,14 +16,8 @@ const path = require('path'); const fs = require('fs'); -const util = require('util'); -const utils = require('./utils'); const os = require('os'); -const removeFolder = require('rimraf'); -const mkdtempAsync = util.promisify(fs.mkdtemp); -const removeFolderAsync = util.promisify(removeFolder); - -const {FFOX, CHROMIUM, WEBKIT, CHANNEL} = testOptions; +const {mkdtempAsync, removeFolderAsync} = require('./utils'); registerFixture('downloadsPath', async ({}, test) => { const downloadsPath = await mkdtempAsync(path.join(os.tmpdir(), 'playwright-test-')); diff --git a/test/utils.js b/test/utils.js index 9ea31ce3db13b..0e6cf6a9992ee 100644 --- a/test/utils.js +++ b/test/utils.js @@ -24,12 +24,13 @@ const removeFolder = require('rimraf'); const {FlakinessDashboard} = require('../utils/flakiness-dashboard'); const PROJECT_ROOT = fs.existsSync(path.join(__dirname, '..', 'package.json')) ? path.join(__dirname, '..') : path.join(__dirname, '..', '..'); -const mkdtempAsync = util.promisify(require('fs').mkdtemp); -const removeFolderAsync = util.promisify(removeFolder); - let platform = os.platform(); const utils = module.exports = { + mkdtempAsync: util.promisify(fs.mkdtemp), + + removeFolderAsync: util.promisify(removeFolder), + /** * @return {string} */ @@ -180,11 +181,11 @@ const utils = module.exports = { }, makeUserDataDir: async function() { - return await mkdtempAsync(path.join(os.tmpdir(), 'playwright_dev_profile-')); + return await utils.mkdtempAsync(path.join(os.tmpdir(), 'playwright_dev_profile-')); }, removeUserDataDir: async function(dir) { - await removeFolderAsync(dir).catch(e => {}); + await utils.removeFolderAsync(dir).catch(e => {}); }, testOptions(browserType) {