Skip to content

Commit

Permalink
tests(watch): use copyFile functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
hemal7735 committed Jan 21, 2019
1 parent 5078914 commit ce7ab1c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 43 deletions.
Expand Up @@ -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(() => {
Expand Down
Expand Up @@ -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(() => {
Expand Down
Expand Up @@ -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(() => {
Expand Down
10 changes: 3 additions & 7 deletions test/binCases/watch/multi-config/multi-config.test.js
Expand Up @@ -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(() => {
Expand Down
Expand Up @@ -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(() => {
Expand Down
13 changes: 4 additions & 9 deletions 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(() => {
Expand Down

0 comments on commit ce7ab1c

Please sign in to comment.