diff --git a/test/watch/index.js b/test/watch/index.js index 537126d98e8..bf542382572 100644 --- a/test/watch/index.js +++ b/test/watch/index.js @@ -9,7 +9,7 @@ const { } = require('fs'); const { resolve } = require('path'); const process = require('process'); -const { copy, removeSync } = require('fs-extra'); +const { copy, remove, removeSync } = require('fs-extra'); const sander = require('sander'); const rollup = require('../../dist/rollup'); @@ -24,9 +24,9 @@ function wait(ms) { describe('rollup.watch', () => { let watcher; - beforeEach(() => { + beforeEach(async () => { process.chdir(cwd); - return removeSync('test/_tmp'); + await remove('test/_tmp'); }); afterEach(() => { @@ -345,9 +345,9 @@ describe('rollup.watch', () => { 'END', async () => { assert.strictEqual(lastEvent, null); - writeFileSync(WATCHED_ID, 'another'); + await promises.writeFile(WATCHED_ID, 'another'); await wait(100); - unlinkSync(WATCHED_ID); + await promises.unlink(WATCHED_ID); }, 'START', 'BUNDLE_START', @@ -356,11 +356,11 @@ describe('rollup.watch', () => { async () => { assert.strictEqual(lastEvent, 'delete'); lastEvent = null; - writeFileSync(WATCHED_ID, '123'); + await promises.writeFile(WATCHED_ID, '123'); await wait(100); - unlinkSync(WATCHED_ID); + await promises.unlink(WATCHED_ID); // To ensure there is always another change to trigger a rebuild - writeFileSync(MAIN_ID, 'export default 43;'); + await promises.writeFile(MAIN_ID, 'export default 43;'); }, 'START', 'BUNDLE_START', @@ -368,9 +368,9 @@ describe('rollup.watch', () => { 'END', async () => { assert.strictEqual(lastEvent, null); - writeFileSync(WATCHED_ID, '123'); + await promises.writeFile(WATCHED_ID, '123'); await wait(100); - writeFileSync(WATCHED_ID, 'asd'); + await promises.writeFile(WATCHED_ID, 'asd'); }, 'START', 'BUNDLE_START',