Skip to content

Commit c61fe92

Browse files
hemal7735evenstensberg
authored andcommitted
tests(watch): use copyFile functionality
1 parent 1b21e81 commit c61fe92

File tree

6 files changed

+19
-43
lines changed

6 files changed

+19
-43
lines changed

test/binCases/watch/info-verbosity-off/info-verbosity-off.test.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,15 @@ jest.setTimeout(10E6);
55
/* eslint-disable node/no-unsupported-features/es-syntax */
66
const fs = require("fs");
77
const path = require("path");
8-
const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc } = require("../../../testUtils");
8+
const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc, copyFile } = require("../../../testUtils");
99

1010
const fileToChange = "index.js";
11-
const copyFile = "index_copy.js";
1211
const fileToChangePath = path.resolve(__dirname, fileToChange);
13-
const copyFilePath = path.resolve(__dirname, copyFile);
12+
var copyFilePath;
1413

1514
// create copy of "index.js" => "index_copy.js"
1615
beforeEach(() => {
17-
// fs.copyFileSync was added in Added in: v8.5.0
18-
// We should refactor the below code once our minimal supported version is v8.5.0
19-
fs.createReadStream(fileToChangePath).pipe(fs.createWriteStream(copyFilePath));
16+
copyFilePath = copyFile(__dirname, fileToChange);
2017
});
2118

2219
afterEach(() => {

test/binCases/watch/info-verbosity-verbose/info-verbosity-verbose.test.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@
33
jest.setTimeout(10E6);
44
/* eslint-disable node/no-unsupported-features */
55
/* eslint-disable node/no-unsupported-features/es-syntax */
6-
76
const fs = require("fs");
87
const path = require("path");
9-
const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc } = require("../../../testUtils");
8+
const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc, copyFile } = require("../../../testUtils");
109

1110
const fileToChange = "index.js";
12-
const copyFile = "index_copy.js";
1311
const fileToChangePath = path.resolve(__dirname, fileToChange);
14-
const copyFilePath = path.resolve(__dirname, copyFile);
12+
var copyFilePath;
1513

1614
// create copy of "index.js" => "index_copy.js"
1715
beforeEach(() => {
18-
// fs.copyFileSync was added in Added in: v8.5.0
19-
// We should refactor the below code once our minimal supported version is v8.5.0
20-
fs.createReadStream(fileToChangePath).pipe(fs.createWriteStream(copyFilePath));
16+
copyFilePath = copyFile(__dirname, fileToChange);
2117
});
2218

2319
afterEach(() => {

test/binCases/watch/multi-config-watch-opt/multi-config-watch-opt.test.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@
33
jest.setTimeout(10E6);
44
/* eslint-disable node/no-unsupported-features */
55
/* eslint-disable node/no-unsupported-features/es-syntax */
6-
76
const fs = require("fs");
87
const path = require("path");
9-
const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc } = require("../../../testUtils");
8+
const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc, copyFile } = require("../../../testUtils");
109

1110
const fileToChange = "index.js";
12-
const copyFile = "index_copy.js";
1311
const fileToChangePath = path.resolve(__dirname, fileToChange);
14-
const copyFilePath = path.resolve(__dirname, copyFile);
12+
var copyFilePath;
1513

1614
// create copy of "index.js" => "index_copy.js"
1715
beforeEach(() => {
18-
// fs.copyFileSync was added in Added in: v8.5.0
19-
// We should refactor the below code once our minimal supported version is v8.5.0
20-
fs.createReadStream(fileToChangePath).pipe(fs.createWriteStream(copyFilePath));
16+
copyFilePath = copyFile(__dirname, fileToChange);
2117
});
2218

2319
afterEach(() => {

test/binCases/watch/multi-config/multi-config.test.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@
33
jest.setTimeout(10E6);
44
/* eslint-disable node/no-unsupported-features */
55
/* eslint-disable node/no-unsupported-features/es-syntax */
6-
76
const fs = require("fs");
87
const path = require("path");
9-
const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc } = require("../../../testUtils");
8+
const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc, copyFile } = require("../../../testUtils");
109

1110
const fileToChange = "index.js";
12-
const copyFile = "index_copy.js";
1311
const fileToChangePath = path.resolve(__dirname, fileToChange);
14-
const copyFilePath = path.resolve(__dirname, copyFile);
12+
var copyFilePath;
1513

1614
// create copy of "index.js" => "index_copy.js"
1715
beforeEach(() => {
18-
// fs.copyFileSync was added in Added in: v8.5.0
19-
// We should refactor the below code once our minimal supported version is v8.5.0
20-
fs.createReadStream(fileToChangePath).pipe(fs.createWriteStream(copyFilePath));
16+
copyFilePath = copyFile(__dirname, fileToChange);
2117
});
2218

2319
afterEach(() => {

test/binCases/watch/single-config-watch-opt/single-config-watch-opt.test.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@
33
jest.setTimeout(10E6);
44
/* eslint-disable node/no-unsupported-features */
55
/* eslint-disable node/no-unsupported-features/es-syntax */
6-
76
const fs = require("fs");
87
const path = require("path");
9-
const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc } = require("../../../testUtils");
8+
const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc, copyFile } = require("../../../testUtils");
109

1110
const fileToChange = "index.js";
12-
const copyFile = "index_copy.js";
1311
const fileToChangePath = path.resolve(__dirname, fileToChange);
14-
const copyFilePath = path.resolve(__dirname, copyFile);
12+
var copyFilePath;
1513

1614
// create copy of "index.js" => "index_copy.js"
1715
beforeEach(() => {
18-
// fs.copyFileSync was added in Added in: v8.5.0
19-
// We should refactor the below code once our minimal supported version is v8.5.0
20-
fs.createReadStream(fileToChangePath).pipe(fs.createWriteStream(copyFilePath));
16+
copyFilePath = copyFile(__dirname, fileToChange);
2117
});
2218

2319
afterEach(() => {

test/binCases/watch/single-config/single-config.test.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
11
"use strict";
22

3+
jest.setTimeout(10E6);
34
/* eslint-disable node/no-unsupported-features */
45
/* eslint-disable node/no-unsupported-features/es-syntax */
5-
6-
jest.setTimeout(10E6);
7-
86
const fs = require("fs");
97
const path = require("path");
10-
const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc } = require("../../../testUtils");
8+
const { extractSummary, extractHash, appendDataIfFileExists, runAndGetWatchProc, copyFile } = require("../../../testUtils");
119

1210
const fileToChange = "index.js";
13-
const copyFile = "index_copy.js";
1411
const fileToChangePath = path.resolve(__dirname, fileToChange);
15-
const copyFilePath = path.resolve(__dirname, copyFile);
12+
var copyFilePath;
1613

1714
// create copy of "index.js" => "index_copy.js"
1815
beforeEach(() => {
19-
// fs.copyFileSync was added in Added in: v8.5.0
20-
// We should refactor the below code once our minimal supported version is v8.5.0
21-
fs.createReadStream(fileToChangePath).pipe(fs.createWriteStream(copyFilePath));
16+
copyFilePath = copyFile(__dirname, fileToChange);
2217
});
2318

2419
afterEach(() => {

0 commit comments

Comments
 (0)