From ce7ab1cd6ca71091453277940ce064829c19a034 Mon Sep 17 00:00:00 2001 From: Hemal Patel Date: Wed, 16 Jan 2019 10:24:16 +0530 Subject: [PATCH] tests(watch): use copyFile functionality --- .../info-verbosity-off/info-verbosity-off.test.js | 9 +++------ .../info-verbosity-verbose.test.js | 10 +++------- .../multi-config-watch-opt.test.js | 10 +++------- .../watch/multi-config/multi-config.test.js | 10 +++------- .../single-config-watch-opt.test.js | 10 +++------- .../watch/single-config/single-config.test.js | 13 ++++--------- 6 files changed, 19 insertions(+), 43 deletions(-) diff --git a/test/binCases/watch/info-verbosity-off/info-verbosity-off.test.js b/test/binCases/watch/info-verbosity-off/info-verbosity-off.test.js index 86010071ef8..e9e22f2a29b 100644 --- a/test/binCases/watch/info-verbosity-off/info-verbosity-off.test.js +++ b/test/binCases/watch/info-verbosity-off/info-verbosity-off.test.js @@ -5,18 +5,15 @@ jest.setTimeout(10E6); /* eslint-disable node/no-unsupported-features/es-syntax */ const fs = require("fs"); const path = require("path"); -const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc } = require("../../../testUtils"); +const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc, copyFile } = require("../../../testUtils"); const fileToChange = "index.js"; -const copyFile = "index_copy.js"; const fileToChangePath = path.resolve(__dirname, fileToChange); -const copyFilePath = path.resolve(__dirname, copyFile); +var copyFilePath; // create copy of "index.js" => "index_copy.js" beforeEach(() => { - // fs.copyFileSync was added in Added in: v8.5.0 - // We should refactor the below code once our minimal supported version is v8.5.0 - fs.createReadStream(fileToChangePath).pipe(fs.createWriteStream(copyFilePath)); + copyFilePath = copyFile(__dirname, fileToChange); }); afterEach(() => { diff --git a/test/binCases/watch/info-verbosity-verbose/info-verbosity-verbose.test.js b/test/binCases/watch/info-verbosity-verbose/info-verbosity-verbose.test.js index 6730cbf832c..d6bd1d865bb 100644 --- a/test/binCases/watch/info-verbosity-verbose/info-verbosity-verbose.test.js +++ b/test/binCases/watch/info-verbosity-verbose/info-verbosity-verbose.test.js @@ -3,21 +3,17 @@ jest.setTimeout(10E6); /* eslint-disable node/no-unsupported-features */ /* eslint-disable node/no-unsupported-features/es-syntax */ - const fs = require("fs"); const path = require("path"); -const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc } = require("../../../testUtils"); +const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc, copyFile } = require("../../../testUtils"); const fileToChange = "index.js"; -const copyFile = "index_copy.js"; const fileToChangePath = path.resolve(__dirname, fileToChange); -const copyFilePath = path.resolve(__dirname, copyFile); +var copyFilePath; // create copy of "index.js" => "index_copy.js" beforeEach(() => { - // fs.copyFileSync was added in Added in: v8.5.0 - // We should refactor the below code once our minimal supported version is v8.5.0 - fs.createReadStream(fileToChangePath).pipe(fs.createWriteStream(copyFilePath)); + copyFilePath = copyFile(__dirname, fileToChange); }); afterEach(() => { diff --git a/test/binCases/watch/multi-config-watch-opt/multi-config-watch-opt.test.js b/test/binCases/watch/multi-config-watch-opt/multi-config-watch-opt.test.js index 0976270f255..b4ffc2acb8f 100644 --- a/test/binCases/watch/multi-config-watch-opt/multi-config-watch-opt.test.js +++ b/test/binCases/watch/multi-config-watch-opt/multi-config-watch-opt.test.js @@ -3,21 +3,17 @@ jest.setTimeout(10E6); /* eslint-disable node/no-unsupported-features */ /* eslint-disable node/no-unsupported-features/es-syntax */ - const fs = require("fs"); const path = require("path"); -const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc } = require("../../../testUtils"); +const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc, copyFile } = require("../../../testUtils"); const fileToChange = "index.js"; -const copyFile = "index_copy.js"; const fileToChangePath = path.resolve(__dirname, fileToChange); -const copyFilePath = path.resolve(__dirname, copyFile); +var copyFilePath; // create copy of "index.js" => "index_copy.js" beforeEach(() => { - // fs.copyFileSync was added in Added in: v8.5.0 - // We should refactor the below code once our minimal supported version is v8.5.0 - fs.createReadStream(fileToChangePath).pipe(fs.createWriteStream(copyFilePath)); + copyFilePath = copyFile(__dirname, fileToChange); }); afterEach(() => { diff --git a/test/binCases/watch/multi-config/multi-config.test.js b/test/binCases/watch/multi-config/multi-config.test.js index 7a92029d5cc..03261f08fcd 100644 --- a/test/binCases/watch/multi-config/multi-config.test.js +++ b/test/binCases/watch/multi-config/multi-config.test.js @@ -3,21 +3,17 @@ jest.setTimeout(10E6); /* eslint-disable node/no-unsupported-features */ /* eslint-disable node/no-unsupported-features/es-syntax */ - const fs = require("fs"); const path = require("path"); -const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc } = require("../../../testUtils"); +const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc, copyFile } = require("../../../testUtils"); const fileToChange = "index.js"; -const copyFile = "index_copy.js"; const fileToChangePath = path.resolve(__dirname, fileToChange); -const copyFilePath = path.resolve(__dirname, copyFile); +var copyFilePath; // create copy of "index.js" => "index_copy.js" beforeEach(() => { - // fs.copyFileSync was added in Added in: v8.5.0 - // We should refactor the below code once our minimal supported version is v8.5.0 - fs.createReadStream(fileToChangePath).pipe(fs.createWriteStream(copyFilePath)); + copyFilePath = copyFile(__dirname, fileToChange); }); afterEach(() => { diff --git a/test/binCases/watch/single-config-watch-opt/single-config-watch-opt.test.js b/test/binCases/watch/single-config-watch-opt/single-config-watch-opt.test.js index 249cd3d7853..e52fca6a73c 100644 --- a/test/binCases/watch/single-config-watch-opt/single-config-watch-opt.test.js +++ b/test/binCases/watch/single-config-watch-opt/single-config-watch-opt.test.js @@ -3,21 +3,17 @@ jest.setTimeout(10E6); /* eslint-disable node/no-unsupported-features */ /* eslint-disable node/no-unsupported-features/es-syntax */ - const fs = require("fs"); const path = require("path"); -const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc } = require("../../../testUtils"); +const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc, copyFile } = require("../../../testUtils"); const fileToChange = "index.js"; -const copyFile = "index_copy.js"; const fileToChangePath = path.resolve(__dirname, fileToChange); -const copyFilePath = path.resolve(__dirname, copyFile); +var copyFilePath; // create copy of "index.js" => "index_copy.js" beforeEach(() => { - // fs.copyFileSync was added in Added in: v8.5.0 - // We should refactor the below code once our minimal supported version is v8.5.0 - fs.createReadStream(fileToChangePath).pipe(fs.createWriteStream(copyFilePath)); + copyFilePath = copyFile(__dirname, fileToChange); }); afterEach(() => { diff --git a/test/binCases/watch/single-config/single-config.test.js b/test/binCases/watch/single-config/single-config.test.js index d3bb2f554b0..0f5b5b2ae15 100644 --- a/test/binCases/watch/single-config/single-config.test.js +++ b/test/binCases/watch/single-config/single-config.test.js @@ -1,24 +1,19 @@ "use strict"; +jest.setTimeout(10E6); /* eslint-disable node/no-unsupported-features */ /* eslint-disable node/no-unsupported-features/es-syntax */ - -jest.setTimeout(10E6); - const fs = require("fs"); const path = require("path"); -const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc } = require("../../../testUtils"); +const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc, copyFile } = require("../../../testUtils"); const fileToChange = "index.js"; -const copyFile = "index_copy.js"; const fileToChangePath = path.resolve(__dirname, fileToChange); -const copyFilePath = path.resolve(__dirname, copyFile); +var copyFilePath; // create copy of "index.js" => "index_copy.js" beforeEach(() => { - // fs.copyFileSync was added in Added in: v8.5.0 - // We should refactor the below code once our minimal supported version is v8.5.0 - fs.createReadStream(fileToChangePath).pipe(fs.createWriteStream(copyFilePath)); + copyFilePath = copyFile(__dirname, fileToChange); }); afterEach(() => {