Best JavaScript code snippet using storybook-root
prestart.ts
Source:prestart.ts
1import "mocha";2import { assert } from "chai";3import * as mock from "mock-require";4import * as sinon from "sinon";5// Using `let` and `require` so `mock.reRequire` is legal later.6let prestart = require('../prestart');7describe("prestart", function() {8 describe("buildPackageList", function() {9 it("rejects null", function () {10 assert.throws(() => prestart.buildPackageList(null));11 });12 it("builds a list with no deps", function() {13 assert.deepEqual(14 prestart.buildPackageList({}),15 []);16 });17 it("builds a list with multiple deps", function() {18 assert.deepEqual(19 prestart.buildPackageList({20 "is-thirteen": "2.0.0",21 "lodash": "4.0.0",22 }),23 ["is-thirteen@2.0.0", "lodash@4.0.0"]);24 });25 });26 describe("addYarn", function() {27 it("rejects null", function() {28 assert.throws(() => prestart.addYarn(null));29 });30 it("rejects the empty list", function() {31 assert.throws(() => prestart.addYarn([]));32 });33 describe("mocked", function() {34 let execFileSync;35 beforeEach(function() {36 execFileSync = sinon.stub();37 mock("child_process", { execFileSync });38 prestart = mock.reRequire("../prestart");39 });40 afterEach(function() {41 mock.stopAll();42 });43 it("invokes execFileSync for a single package", function () {44 try {45 prestart.addYarn(["is-thirteen@2.0.0"]);46 } finally {47 mock.stopAll();48 }49 sinon.assert.calledOnce(execFileSync);50 sinon.assert.calledWithExactly(51 execFileSync, "yarn", ["add", "is-thirteen@2.0.0"]);52 });53 it("invokes execFileSync for multiple packages", function () {54 try {55 prestart.addYarn(["is-thirteen@2.0.0", "lodash@4.0.0"]);56 } finally {57 mock.stopAll();58 }59 sinon.assert.calledOnce(execFileSync);60 sinon.assert.calledWithExactly(61 execFileSync, "yarn", ["add", "is-thirteen@2.0.0", "lodash@4.0.0"]);62 });63 });64 });65 describe("createConfig", function () {66 let67 existsSync: sinon.SinonStub,68 readFileSync: sinon.SinonStub,69 writeFileSync: sinon.SinonStub;70 beforeEach(function() {71 existsSync = sinon.stub();72 readFileSync = sinon.stub();73 readFileSync.callsFake(() => "{}");74 writeFileSync = sinon.stub();75 mock("fs", { existsSync, readFileSync, writeFileSync });76 prestart = mock.reRequire("../prestart");77 });78 afterEach(function() {79 mock.stopAll();80 });81 it("no brigade.json", function() {82 existsSync.callsFake(() => false);83 prestart.createConfig();84 assert.equal(existsSync.getCalls().length, 5);85 assert.deepEqual(existsSync.getCall(0).args, [process.env.BRIGADE_CONFIG]);86 assert.deepEqual(existsSync.getCall(1).args, [prestart.mountedConfigFile]);87 assert.deepEqual(existsSync.getCall(2).args, [prestart.vcsConfigFile]);88 assert.deepEqual(existsSync.getCall(3).args, [prestart.defaultProjectConfigFile]);89 assert.deepEqual(existsSync.getCall(4).args, [prestart.configMapConfigFile]);90 sinon.assert.notCalled(writeFileSync);91 });92 it("config exists via env var", function() {93 existsSync.callsFake((...args) => {94 return args[0] === process.env.BRIGADE_CONFIG;95 });96 prestart.createConfig();97 assert.equal(existsSync.getCalls().length, 1);98 assert.deepEqual(existsSync.getCall(0).args, [process.env.BRIGADE_CONFIG]);99 sinon.assert.called(writeFileSync);100 sinon.assert.calledWithExactly(writeFileSync, prestart.configFile, "{}");101 });102 it("config exists via mounted file", function() {103 existsSync.callsFake((...args) => {104 return args[0] === prestart.mountedConfigFile;105 });106 prestart.createConfig();107 assert.equal(existsSync.getCalls().length, 2);108 assert.deepEqual(existsSync.getCall(0).args, [process.env.BRIGADE_CONFIG]);109 assert.deepEqual(existsSync.getCall(1).args, [prestart.mountedConfigFile]);110 sinon.assert.called(writeFileSync);111 sinon.assert.calledWithExactly(writeFileSync, prestart.configFile, "{}");112 });113 it("no brigade.json mounted, but exists in vcs", function() {114 existsSync.callsFake((...args) => {115 return args[0] === prestart.vcsConfigFile;116 });117 prestart.createConfig();118 assert.equal(existsSync.getCalls().length, 3);119 assert.deepEqual(existsSync.getCall(0).args, [process.env.BRIGADE_CONFIG]);120 assert.deepEqual(existsSync.getCall(1).args, [prestart.mountedConfigFile]);121 assert.deepEqual(existsSync.getCall(2).args, [prestart.vcsConfigFile]);122 sinon.assert.called(writeFileSync);123 sinon.assert.calledWithExactly(writeFileSync, prestart.configFile, "{}");124 });125 it("config exists via project default", function() {126 existsSync.callsFake((...args) => {127 return args[0] === prestart.defaultProjectConfigFile;128 });129 prestart.createConfig();130 assert.equal(existsSync.getCalls().length, 4);131 assert.deepEqual(existsSync.getCall(0).args, [process.env.BRIGADE_CONFIG]);132 assert.deepEqual(existsSync.getCall(1).args, [prestart.mountedConfigFile]);133 assert.deepEqual(existsSync.getCall(2).args, [prestart.vcsConfigFile]);134 assert.deepEqual(existsSync.getCall(3).args, [prestart.defaultProjectConfigFile]);135 sinon.assert.called(writeFileSync);136 sinon.assert.calledWithExactly(writeFileSync, prestart.configFile, "{}");137 });138 it("config exists via config map", function() {139 existsSync.callsFake((...args) => {140 return args[0] === prestart.configMapConfigFile;141 });142 prestart.createConfig();143 assert.equal(existsSync.getCalls().length, 5);144 assert.deepEqual(existsSync.getCall(0).args, [process.env.BRIGADE_CONFIG]);145 assert.deepEqual(existsSync.getCall(1).args, [prestart.mountedConfigFile]);146 assert.deepEqual(existsSync.getCall(2).args, [prestart.vcsConfigFile]);147 assert.deepEqual(existsSync.getCall(3).args, [prestart.defaultProjectConfigFile]);148 assert.deepEqual(existsSync.getCall(4).args, [prestart.configMapConfigFile]);149 sinon.assert.called(writeFileSync);150 sinon.assert.calledWithExactly(writeFileSync, prestart.configFile, "{}");151 });152 });153 describe("addDeps", function () {154 let155 execFileSync: sinon.SinonStub,156 existsSync: sinon.SinonStub,157 readFileSync: sinon.SinonStub,158 writeFileSync: sinon.SinonStub,159 exit: sinon.SinonStub;160 beforeEach(function() {161 execFileSync = sinon.stub();162 mock("child_process", { execFileSync });163 existsSync = sinon.stub();164 readFileSync = sinon.stub();165 writeFileSync = sinon.stub();166 mock("fs", { existsSync, readFileSync, writeFileSync });167 exit = sinon.stub();168 mock("process", { env: {}, exit });169 sinon.stub(console, 'error');170 prestart = mock.reRequire("../prestart");171 });172 afterEach(function() {173 mock.stopAll();174 (console as any).error.restore();175 });176 it("no config file exists", function() {177 existsSync.callsFake(() => false);178 prestart.addDeps();179 assert.equal(existsSync.getCalls().length, 6);180 assert.deepEqual(existsSync.getCall(0).args, [process.env.BRIGADE_CONFIG]);181 assert.deepEqual(existsSync.getCall(1).args, [prestart.mountedConfigFile]);182 assert.deepEqual(existsSync.getCall(2).args, [prestart.vcsConfigFile]);183 assert.deepEqual(existsSync.getCall(3).args, [prestart.defaultProjectConfigFile]);184 assert.deepEqual(existsSync.getCall(4).args, [prestart.configMapConfigFile]);185 assert.deepEqual(existsSync.getCall(5).args, [prestart.configFile]);186 sinon.assert.notCalled(execFileSync);187 sinon.assert.notCalled(exit);188 });189 it("no dependencies object", function() {190 mock(prestart.configFile, {});191 existsSync.callsFake(() => true);192 prestart.addDeps();193 assert.equal(existsSync.getCalls().length, 2);194 assert.deepEqual(existsSync.getCall(0).args, [process.env.BRIGADE_CONFIG]);195 assert.deepEqual(existsSync.getCall(1).args, [prestart.configFile]);196 sinon.assert.notCalled(execFileSync);197 sinon.assert.notCalled(exit);198 });199 it("empty dependencies", function() {200 mock(prestart.configFile, { dependencies: {}})201 existsSync.callsFake(() => true);202 prestart.addDeps();203 assert.equal(existsSync.getCalls().length, 2);204 assert.deepEqual(existsSync.getCall(0).args, [process.env.BRIGADE_CONFIG]);205 assert.deepEqual(existsSync.getCall(1).args, [prestart.configFile]);206 sinon.assert.notCalled(execFileSync);207 sinon.assert.notCalled(exit);208 });209 it("one dependency", function() {210 mock(prestart.configFile, {211 dependencies: {212 "is-thirteen": "2.0.0",213 },214 });215 existsSync.callsFake(() => true);216 prestart.addDeps();217 assert.equal(existsSync.getCalls().length, 2);218 assert.deepEqual(existsSync.getCall(0).args, [process.env.BRIGADE_CONFIG]);219 assert.deepEqual(existsSync.getCall(1).args, [prestart.configFile]);220 sinon.assert.calledOnce(execFileSync);221 sinon.assert.calledWithExactly(222 execFileSync, "yarn", ["add", "is-thirteen@2.0.0"]);223 sinon.assert.notCalled(exit);224 })225 it("two dependencies", function() {226 mock(prestart.configFile, {227 dependencies: {228 "is-thirteen": "2.0.0",229 "lodash": "4.0.0",230 },231 });232 existsSync.callsFake(() => true);233 prestart.addDeps();234 assert.equal(existsSync.getCalls().length, 2);235 assert.deepEqual(existsSync.getCall(0).args, [process.env.BRIGADE_CONFIG]);236 assert.deepEqual(existsSync.getCall(1).args, [prestart.configFile]);237 sinon.assert.calledOnce(execFileSync);238 sinon.assert.calledWithExactly(239 execFileSync, "yarn", ["add", "is-thirteen@2.0.0", "lodash@4.0.0"]);240 sinon.assert.notCalled(exit);241 });242 it("yarn error", function() {243 mock(prestart.configFile, {244 dependencies: {245 "is-thirteen": "2.0.0",246 },247 });248 existsSync.callsFake(() => true);249 execFileSync.callsFake(() => {250 const e = new Error('Command failed: yarn');251 (e as any).status = 1;252 throw e;253 });254 prestart.addDeps();255 assert.equal(existsSync.getCalls().length, 2);256 assert.deepEqual(existsSync.getCall(0).args, [process.env.BRIGADE_CONFIG]);257 assert.deepEqual(existsSync.getCall(1).args, [prestart.configFile]);258 sinon.assert.calledOnce(execFileSync);259 sinon.assert.calledWithExactly(execFileSync, "yarn", ["add", "is-thirteen@2.0.0"]);260 sinon.assert.calledOnce(exit);261 sinon.assert.calledWithExactly(exit, 1);262 });263 });...
config-database.test.ts
Source:config-database.test.ts
1import { Console } from "@packages/core-test-framework";2import { Command } from "@packages/core/src/commands/config-database";3import envfile from "envfile";4import fs from "fs-extra";5import prompts from "prompts";6import { dirSync, setGracefulCleanup } from "tmp";7let cli;8let envFile: string;9beforeEach(() => {10 process.env.CORE_PATH_CONFIG = dirSync().name;11 envFile = `${process.env.CORE_PATH_CONFIG}/.env`;12 cli = new Console();13});14afterAll(() => setGracefulCleanup());15describe("DatabaseCommand", () => {16 describe("Flags", () => {17 it("should throw if the .env file does not exist", async () => {18 await expect(cli.withFlags({ host: "localhost" }).execute(Command)).rejects.toThrow(19 `No environment file found at ${process.env.CORE_PATH_CONFIG}/.env.`,20 );21 });22 it("should set the database host", async () => {23 // Arrange24 const existsSync = jest.spyOn(fs, "existsSync").mockReturnValueOnce(true);25 const parseFileSync = jest.spyOn(envfile, "parseFileSync").mockImplementation(() => ({}));26 const writeFileSync = jest.spyOn(fs, "writeFileSync").mockImplementation();27 // Act28 await cli.withFlags({ host: "localhost" }).execute(Command);29 // Assert30 expect(existsSync).toHaveBeenCalledWith(envFile);31 expect(parseFileSync).toHaveBeenCalledWith(envFile);32 expect(writeFileSync).toHaveBeenCalledWith(envFile, "CORE_DB_HOST=localhost");33 // Reset34 existsSync.mockReset();35 parseFileSync.mockReset();36 writeFileSync.mockReset();37 });38 it("should set the database port", async () => {39 // Arrange40 const existsSync = jest.spyOn(fs, "existsSync").mockReturnValueOnce(true);41 const parseFileSync = jest.spyOn(envfile, "parseFileSync").mockImplementation(() => ({}));42 const writeFileSync = jest.spyOn(fs, "writeFileSync").mockImplementation();43 // Act44 await cli.withFlags({ port: "5432" }).execute(Command);45 // Assert46 expect(existsSync).toHaveBeenCalledWith(envFile);47 expect(parseFileSync).toHaveBeenCalledWith(envFile);48 expect(writeFileSync).toHaveBeenCalledWith(envFile, "CORE_DB_PORT=5432");49 // Reset50 existsSync.mockReset();51 parseFileSync.mockReset();52 writeFileSync.mockReset();53 });54 it("should set the database name", async () => {55 // Arrange56 const existsSync = jest.spyOn(fs, "existsSync").mockReturnValueOnce(true);57 const parseFileSync = jest.spyOn(envfile, "parseFileSync").mockImplementation(() => ({}));58 const writeFileSync = jest.spyOn(fs, "writeFileSync").mockImplementation();59 // Act60 await cli.withFlags({ database: "ark_mainnet" }).execute(Command);61 // Assert62 expect(existsSync).toHaveBeenCalledWith(envFile);63 expect(parseFileSync).toHaveBeenCalledWith(envFile);64 expect(writeFileSync).toHaveBeenCalledWith(envFile, "CORE_DB_DATABASE=ark_mainnet");65 // Reset66 existsSync.mockReset();67 parseFileSync.mockReset();68 writeFileSync.mockReset();69 });70 it("should set the name of the database user", async () => {71 // Arrange72 const existsSync = jest.spyOn(fs, "existsSync").mockReturnValueOnce(true);73 const parseFileSync = jest.spyOn(envfile, "parseFileSync").mockImplementation(() => ({}));74 const writeFileSync = jest.spyOn(fs, "writeFileSync").mockImplementation();75 // Act76 await cli.withFlags({ username: "ark" }).execute(Command, { flags: { username: "ark" } });77 // Assert78 expect(existsSync).toHaveBeenCalledWith(envFile);79 expect(parseFileSync).toHaveBeenCalledWith(envFile);80 expect(writeFileSync).toHaveBeenCalledWith(envFile, "CORE_DB_USERNAME=ark");81 // Reset82 existsSync.mockReset();83 parseFileSync.mockReset();84 writeFileSync.mockReset();85 });86 it("should set the database password", async () => {87 // Arrange88 const existsSync = jest.spyOn(fs, "existsSync").mockReturnValueOnce(true);89 const parseFileSync = jest.spyOn(envfile, "parseFileSync").mockImplementation(() => ({}));90 const writeFileSync = jest.spyOn(fs, "writeFileSync").mockImplementation();91 // Act92 await cli.withFlags({ password: "password" }).execute(Command, { flags: { password: "password" } });93 // Assert94 expect(existsSync).toHaveBeenCalledWith(envFile);95 expect(parseFileSync).toHaveBeenCalledWith(envFile);96 expect(writeFileSync).toHaveBeenCalledWith(envFile, "CORE_DB_PASSWORD=password");97 // Reset98 existsSync.mockReset();99 parseFileSync.mockReset();100 writeFileSync.mockReset();101 });102 });103 describe("Prompts", () => {104 it("should throw if the .env file does not exist", async () => {105 await expect(cli.withFlags({ host: "localhost" }).execute(Command)).rejects.toThrow(106 `No environment file found at ${process.env.CORE_PATH_CONFIG}/.env.`,107 );108 });109 it("should set the database host", async () => {110 // Arrange111 const existsSync = jest.spyOn(fs, "existsSync").mockReturnValueOnce(true);112 const parseFileSync = jest.spyOn(envfile, "parseFileSync").mockImplementation(() => ({}));113 const writeFileSync = jest.spyOn(fs, "writeFileSync").mockImplementation();114 // Act115 prompts.inject(["localhost", undefined, undefined, undefined, undefined, true]);116 await cli.execute(Command);117 // Assert118 expect(existsSync).toHaveBeenCalledWith(envFile);119 expect(parseFileSync).toHaveBeenCalledWith(envFile);120 expect(writeFileSync).toHaveBeenCalledWith(envFile, expect.toInclude("CORE_DB_HOST=localhost"));121 // Reset122 existsSync.mockReset();123 parseFileSync.mockReset();124 writeFileSync.mockReset();125 });126 it("should set the database port", async () => {127 // Arrange128 const existsSync = jest.spyOn(fs, "existsSync").mockReturnValueOnce(true);129 const parseFileSync = jest.spyOn(envfile, "parseFileSync").mockImplementation(() => ({}));130 const writeFileSync = jest.spyOn(fs, "writeFileSync").mockImplementation();131 // Act132 prompts.inject([undefined, 5000, undefined, undefined, undefined, true]);133 await cli.execute(Command);134 // Assert135 expect(existsSync).toHaveBeenCalledWith(envFile);136 expect(parseFileSync).toHaveBeenCalledWith(envFile);137 expect(writeFileSync).toHaveBeenCalledWith(envFile, expect.toInclude("CORE_DB_PORT=5000"));138 // Reset139 existsSync.mockReset();140 parseFileSync.mockReset();141 writeFileSync.mockReset();142 });143 it("should set the database name", async () => {144 // Arrange145 const existsSync = jest.spyOn(fs, "existsSync").mockReturnValueOnce(true);146 const parseFileSync = jest.spyOn(envfile, "parseFileSync").mockImplementation(() => ({}));147 const writeFileSync = jest.spyOn(fs, "writeFileSync").mockImplementation();148 // Act149 prompts.inject([undefined, undefined, "ark_mainnet", undefined, undefined, true]);150 await cli.execute(Command);151 // Assert152 expect(existsSync).toHaveBeenCalledWith(envFile);153 expect(parseFileSync).toHaveBeenCalledWith(envFile);154 expect(writeFileSync).toHaveBeenCalledWith(envFile, expect.toInclude("CORE_DB_DATABASE=ark_mainnet"));155 // Reset156 existsSync.mockReset();157 parseFileSync.mockReset();158 writeFileSync.mockReset();159 });160 it("should set the name of the database user", async () => {161 // Arrange162 const existsSync = jest.spyOn(fs, "existsSync").mockReturnValueOnce(true);163 const parseFileSync = jest.spyOn(envfile, "parseFileSync").mockImplementation(() => ({}));164 const writeFileSync = jest.spyOn(fs, "writeFileSync").mockImplementation();165 // Act166 prompts.inject([undefined, undefined, undefined, "ark", undefined, true]);167 await cli.execute(Command);168 // Assert169 expect(existsSync).toHaveBeenCalledWith(envFile);170 expect(parseFileSync).toHaveBeenCalledWith(envFile);171 expect(writeFileSync).toHaveBeenCalledWith(envFile, expect.toInclude("CORE_DB_USERNAME=ark"));172 // Reset173 existsSync.mockReset();174 parseFileSync.mockReset();175 writeFileSync.mockReset();176 });177 it("should set the database password", async () => {178 // Arrange179 const existsSync = jest.spyOn(fs, "existsSync").mockReturnValueOnce(true);180 const parseFileSync = jest.spyOn(envfile, "parseFileSync").mockImplementation(() => ({}));181 const writeFileSync = jest.spyOn(fs, "writeFileSync").mockImplementation();182 // Act183 prompts.inject([undefined, undefined, undefined, undefined, "password", true]);184 await cli.execute(Command);185 // Assert186 expect(existsSync).toHaveBeenCalledWith(envFile);187 expect(parseFileSync).toHaveBeenCalledWith(envFile);188 expect(writeFileSync).toHaveBeenCalledWith(envFile, expect.toInclude("CORE_DB_PASSWORD=password"));189 // Reset190 existsSync.mockReset();191 parseFileSync.mockReset();192 writeFileSync.mockReset();193 });194 it("should not update without a confirmation", async () => {195 // Arrange196 const existsSync = jest.spyOn(fs, "existsSync").mockReturnValueOnce(true);197 const parseFileSync = jest.spyOn(envfile, "parseFileSync").mockImplementation(() => ({}));198 const writeFileSync = jest.spyOn(fs, "writeFileSync").mockImplementation();199 // Act200 prompts.inject([undefined, undefined, undefined, undefined, "password", false]);201 await expect(cli.execute(Command)).rejects.toThrow("You'll need to confirm the input to continue.");202 // Assert203 expect(existsSync).not.toHaveBeenCalled();204 expect(parseFileSync).not.toHaveBeenCalled();205 expect(writeFileSync).not.toHaveBeenCalled();206 // Reset207 existsSync.mockReset();208 parseFileSync.mockReset();209 writeFileSync.mockReset();210 });211 });...
mv.js
Source:mv.js
...22shell.mv('-f');23assert.ok(shell.error());24shell.mv('-Z', 'tmp/file1', 'tmp/file1'); // option not supported25assert.ok(shell.error());26assert.equal(fs.existsSync('tmp/file1'), true);27shell.mv('asdfasdf', 'tmp'); // source does not exist28assert.ok(shell.error());29assert.equal(numLines(shell.error()), 1);30assert.equal(fs.existsSync('tmp/asdfasdf'), false);31shell.mv('asdfasdf1', 'asdfasdf2', 'tmp'); // sources do not exist32assert.ok(shell.error());33assert.equal(numLines(shell.error()), 2);34assert.equal(fs.existsSync('tmp/asdfasdf1'), false);35assert.equal(fs.existsSync('tmp/asdfasdf2'), false);36shell.mv('asdfasdf1', 'asdfasdf2', 'tmp/file1'); // too many sources (dest is file)37assert.ok(shell.error());38shell.mv('tmp/file1', 'tmp/file2'); // dest already exists39assert.ok(shell.error());40shell.mv('tmp/file1', 'tmp/file2', 'tmp/a_file'); // too many sources (exist, but dest is file)41assert.ok(shell.error());42assert.equal(fs.existsSync('tmp/a_file'), false);43shell.mv('tmp/file*', 'tmp/file1'); // can't use wildcard when dest is file44assert.ok(shell.error());45assert.equal(fs.existsSync('tmp/file1'), true);46assert.equal(fs.existsSync('tmp/file2'), true);47assert.equal(fs.existsSync('tmp/file1.js'), true);48assert.equal(fs.existsSync('tmp/file2.js'), true);49//50// Valids51//52shell.cd('tmp');53// handles self OK54shell.mkdir('tmp2');55shell.mv('*', 'tmp2'); // has to handle self (tmp2 --> tmp2) without throwing error56assert.ok(shell.error()); // there's an error, but not fatal57assert.equal(fs.existsSync('tmp2/file1'), true); // moved OK58shell.mv('tmp2/*', '.'); // revert59assert.equal(fs.existsSync('file1'), true); // moved OK60shell.mv('file1', 'file3'); // one source61assert.equal(shell.error(), null);62assert.equal(fs.existsSync('file1'), false);63assert.equal(fs.existsSync('file3'), true);64shell.mv('file3', 'file1'); // revert65assert.equal(shell.error(), null);66assert.equal(fs.existsSync('file1'), true);67// two sources68shell.rm('-rf', 't');69shell.mkdir('-p', 't');70shell.mv('file1', 'file2', 't');71assert.equal(shell.error(), null);72assert.equal(fs.existsSync('file1'), false);73assert.equal(fs.existsSync('file2'), false);74assert.equal(fs.existsSync('t/file1'), true);75assert.equal(fs.existsSync('t/file2'), true);76shell.mv('t/*', '.'); // revert77assert.equal(fs.existsSync('file1'), true);78assert.equal(fs.existsSync('file2'), true);79// two sources, array style80shell.rm('-rf', 't');81shell.mkdir('-p', 't');82shell.mv(['file1', 'file2'], 't'); // two sources83assert.equal(shell.error(), null);84assert.equal(fs.existsSync('file1'), false);85assert.equal(fs.existsSync('file2'), false);86assert.equal(fs.existsSync('t/file1'), true);87assert.equal(fs.existsSync('t/file2'), true);88shell.mv('t/*', '.'); // revert89assert.equal(fs.existsSync('file1'), true);90assert.equal(fs.existsSync('file2'), true);91shell.mv('file*.js', 't'); // wildcard92assert.equal(shell.error(), null);93assert.equal(fs.existsSync('file1.js'), false);94assert.equal(fs.existsSync('file2.js'), false);95assert.equal(fs.existsSync('t/file1.js'), true);96assert.equal(fs.existsSync('t/file2.js'), true);97shell.mv('t/*', '.'); // revert98assert.equal(fs.existsSync('file1.js'), true);99assert.equal(fs.existsSync('file2.js'), true);100shell.mv('-f', 'file1', 'file2'); // dest exists, but -f given101assert.equal(shell.error(), null);102assert.equal(fs.existsSync('file1'), false);103assert.equal(fs.existsSync('file2'), true);...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!