How to use fs.remove method in Cypress

Best JavaScript code snippet using cypress

index.test.js

Source:index.test.js Github

copy

Full Screen

...55}56describe('500 Page Support', () => {57 describe('dev mode', () => {58 beforeAll(async () => {59 await fs.remove(join(appDir, '.next'))60 appPort = await findPort()61 app = await launchApp(appDir, appPort)62 })63 afterAll(() => killApp(app))64 runTests('dev')65 })66 describe('server mode', () => {67 beforeAll(async () => {68 await fs.remove(join(appDir, '.next'))69 await nextBuild(appDir)70 appPort = await findPort()71 app = await nextStart(appDir, appPort)72 })73 afterAll(() => killApp(app))74 runTests('server')75 })76 describe('serverless mode', () => {77 beforeAll(async () => {78 nextConfigContent = await fs.readFile(nextConfig, 'utf8')79 await fs.writeFile(80 nextConfig,81 `82 module.exports = {83 target: 'serverless'84 }85 `86 )87 await fs.remove(join(appDir, '.next'))88 await nextBuild(appDir)89 appPort = await findPort()90 app = await nextStart(appDir, appPort)91 })92 afterAll(async () => {93 await fs.writeFile(nextConfig, nextConfigContent)94 await killApp(app)95 })96 runTests('serverless')97 })98 it('still builds 500 statically with getInitialProps in _app', async () => {99 await fs.writeFile(100 pagesApp,101 `102 import App from 'next/app'103 const page = ({ Component, pageProps }) => <Component {...pageProps} />104 page.getInitialProps = (ctx) => App.getInitialProps(ctx)105 export default page106 `107 )108 await fs.remove(join(appDir, '.next'))109 const { stderr, stdout: buildStdout, code } = await nextBuild(appDir, [], {110 stderr: true,111 stdout: true,112 })113 await fs.remove(pagesApp)114 expect(stderr).not.toMatch(gip500Err)115 expect(buildStdout).toContain('rendered 500')116 expect(code).toBe(0)117 expect(118 await fs.pathExists(join(appDir, '.next/server/pages/500.html'))119 ).toBe(true)120 let appStdout = ''121 const appPort = await findPort()122 const app = await nextStart(appDir, appPort, {123 onStderr(msg) {124 appStdout += msg || ''125 },126 })127 await renderViaHTTP(appPort, '/err')128 await killApp(app)129 expect(appStdout).not.toContain('rendered 500')130 })131 it('builds 500 statically by default with no pages/500', async () => {132 await fs.rename(pages500, `${pages500}.bak`)133 await fs.remove(join(appDir, '.next'))134 const { stderr, code } = await nextBuild(appDir, [], { stderr: true })135 await fs.rename(`${pages500}.bak`, pages500)136 expect(stderr).not.toMatch(gip500Err)137 expect(code).toBe(0)138 expect(139 await fs.pathExists(join(appDir, '.next/server/pages/500.html'))140 ).toBe(true)141 const pagesManifest = await getPagesManifest(appDir)142 await updatePagesManifest(143 appDir,144 JSON.stringify({145 ...pagesManifest,146 '/500': pagesManifest['/404'].replace('/404', '/500'),147 })148 )149 // ensure static 500 hydrates correctly150 const appPort = await findPort()151 const app = await nextStart(appDir, appPort)152 try {153 const browser = await webdriver(appPort, '/err?hello=world')154 const initialTitle = await browser.eval('document.title')155 await check(async () => {156 const query = await browser.eval(`window.next.router.query`)157 return query.hello === 'world' ? 'success' : 'not yet'158 }, 'success')159 const currentTitle = await browser.eval('document.title')160 expect(initialTitle).toBe(currentTitle)161 expect(initialTitle).toBe('500: Internal Server Error')162 } finally {163 await killApp(app)164 }165 })166 it('builds 500 statically by default with no pages/500 and custom _error without getInitialProps', async () => {167 await fs.rename(pages500, `${pages500}.bak`)168 await fs.writeFile(169 pagesError,170 `171 function Error({ statusCode }) {172 return <p>Error status: {statusCode}</p>173 }174 export default Error175 `176 )177 await fs.remove(join(appDir, '.next'))178 const { stderr: buildStderr, code } = await nextBuild(appDir, [], {179 stderr: true,180 })181 await fs.rename(`${pages500}.bak`, pages500)182 await fs.remove(pagesError)183 console.log(buildStderr)184 expect(buildStderr).not.toMatch(gip500Err)185 expect(code).toBe(0)186 expect(187 await fs.pathExists(join(appDir, '.next/server/pages/500.html'))188 ).toBe(true)189 })190 it('does not build 500 statically with no pages/500 and custom getInitialProps in _error', async () => {191 await fs.rename(pages500, `${pages500}.bak`)192 await fs.writeFile(193 pagesError,194 `195 function Error({ statusCode }) {196 return <p>Error status: {statusCode}</p>197 }198 Error.getInitialProps = ({ req, res, err }) => {199 console.error('called _error.getInitialProps')200 if (req.url === '/500') {201 throw new Error('should not export /500')202 }203 return {204 statusCode: res && res.statusCode ? res.statusCode : err ? err.statusCode : 404205 }206 }207 export default Error208 `209 )210 await fs.remove(join(appDir, '.next'))211 const { stderr: buildStderr, code } = await nextBuild(appDir, [], {212 stderr: true,213 })214 await fs.rename(`${pages500}.bak`, pages500)215 await fs.remove(pagesError)216 console.log(buildStderr)217 expect(buildStderr).not.toMatch(gip500Err)218 expect(code).toBe(0)219 expect(220 await fs.pathExists(join(appDir, '.next/server/pages/500.html'))221 ).toBe(false)222 let appStderr = ''223 const appPort = await findPort()224 const app = await nextStart(appDir, appPort, {225 onStderr(msg) {226 appStderr += msg || ''227 },228 })229 await renderViaHTTP(appPort, '/err')230 await killApp(app)231 expect(appStderr).toContain('called _error.getInitialProps')232 })233 it('shows error with getInitialProps in pages/500 build', async () => {234 await fs.move(pages500, `${pages500}.bak`)235 await fs.writeFile(236 pages500,237 `238 const page = () => 'custom 500 page'239 page.getInitialProps = () => ({ a: 'b' })240 export default page241 `242 )243 await fs.remove(join(appDir, '.next'))244 const { stderr, code } = await nextBuild(appDir, [], { stderr: true })245 await fs.remove(pages500)246 await fs.move(`${pages500}.bak`, pages500)247 expect(stderr).toMatch(gip500Err)248 expect(code).toBe(1)249 })250 it('shows error with getInitialProps in pages/500 dev', async () => {251 await fs.move(pages500, `${pages500}.bak`)252 await fs.writeFile(253 pages500,254 `255 const page = () => 'custom 500 page'256 page.getInitialProps = () => ({ a: 'b' })257 export default page258 `259 )260 let stderr = ''261 appPort = await findPort()262 app = await launchApp(appDir, appPort, {263 onStderr(msg) {264 stderr += msg || ''265 },266 })267 await renderViaHTTP(appPort, '/500')268 await waitFor(1000)269 await killApp(app)270 await fs.remove(pages500)271 await fs.move(`${pages500}.bak`, pages500)272 expect(stderr).toMatch(gip500Err)273 })274 it('does not show error with getStaticProps in pages/500 build', async () => {275 await fs.move(pages500, `${pages500}.bak`)276 await fs.writeFile(277 pages500,278 `279 const page = () => 'custom 500 page'280 export const getStaticProps = () => ({ props: { a: 'b' } })281 export default page282 `283 )284 await fs.remove(join(appDir, '.next'))285 const { stderr, code } = await nextBuild(appDir, [], { stderr: true })286 await fs.remove(pages500)287 await fs.move(`${pages500}.bak`, pages500)288 expect(stderr).not.toMatch(gip500Err)289 expect(code).toBe(0)290 })291 it('does not show error with getStaticProps in pages/500 dev', async () => {292 await fs.move(pages500, `${pages500}.bak`)293 await fs.writeFile(294 pages500,295 `296 const page = () => 'custom 500 page'297 export const getStaticProps = () => ({ props: { a: 'b' } })298 export default page299 `300 )301 let stderr = ''302 appPort = await findPort()303 app = await launchApp(appDir, appPort, {304 onStderr(msg) {305 stderr += msg || ''306 },307 })308 await renderViaHTTP(appPort, '/abc')309 await waitFor(1000)310 await killApp(app)311 await fs.remove(pages500)312 await fs.move(`${pages500}.bak`, pages500)313 expect(stderr).not.toMatch(gip500Err)314 })315 it('shows error with getServerSideProps in pages/500 build', async () => {316 await fs.move(pages500, `${pages500}.bak`)317 await fs.writeFile(318 pages500,319 `320 const page = () => 'custom 500 page'321 export const getServerSideProps = () => ({ props: { a: 'b' } })322 export default page323 `324 )325 await fs.remove(join(appDir, '.next'))326 const { stderr, code } = await nextBuild(appDir, [], { stderr: true })327 await fs.remove(pages500)328 await fs.move(`${pages500}.bak`, pages500)329 expect(stderr).toMatch(gip500Err)330 expect(code).toBe(1)331 })332 it('shows error with getServerSideProps in pages/500 dev', async () => {333 await fs.move(pages500, `${pages500}.bak`)334 await fs.writeFile(335 pages500,336 `337 const page = () => 'custom 500 page'338 export const getServerSideProps = () => ({ props: { a: 'b' } })339 export default page340 `341 )342 let stderr = ''343 appPort = await findPort()344 app = await launchApp(appDir, appPort, {345 onStderr(msg) {346 stderr += msg || ''347 },348 })349 await renderViaHTTP(appPort, '/500')350 await waitFor(1000)351 await killApp(app)352 await fs.remove(pages500)353 await fs.move(`${pages500}.bak`, pages500)354 expect(stderr).toMatch(gip500Err)355 })...

Full Screen

Full Screen

init.js

Source:init.js Github

copy

Full Screen

1const assert = require('chai').assert;2let chai = require("chai");3let chaiAsPromised = require("chai-as-promised");4chai.use(chaiAsPromised);5const fs = require('fs-extra');6const init = require('../../../../packages/etherlime/cli-commands/init/init');7const runCmdHandler = require('../utils/spawn-child-process').runCmdHandler;8const contractsDir = './contracts';9const contractFileDestination = `${contractsDir}/LimeFactory.sol`;10const contractError = "LimeFactory.sol already exists in ./contracts directory. You've probably already initialized etherlime for this project."11const deploymentDir = './deployment';12const deploymentFileDestination = `${deploymentDir}/deploy.js`;13const deploymentError = "deploy.js already exists in ./deployment directory. You've probably already initialized etherlime for this project."14const testDir = './test';15const testFileDestination = `${testDir}/exampleTest.js`;16const testError = "example.js already exists in ./test directory. You've probably already initialized etherlime for this project."17const packageJsonDestination = './package.json';18const gitignoreFileDestination = './.gitignore';19const zkProofDir = './zero-knowledge-proof';20const circuitsDir = './circuits';21const zkProofError = 'circuit.circom already exists in ./zero-knowledge-proof directory. You\'ve probably already initialized etherlime for this project.';22const inputParamsDir = './input';23const zkProofEnabled = true;24describe('Init cli command', () => {25 let currentDir;26 before(async function () {27 currentDir = process.cwd();28 process.chdir('/tmp');29 });30 it('should execute init without parameters', async () => {31 await assert.isFulfilled(init.run(), 'It is successfully executed');32 })33 it('should have contracts folder and example file', async () => {34 let dirExists = fs.existsSync(contractsDir);35 assert.isTrue(dirExists, "The 'contracts' folder should exist.");36 let fileExists = fs.existsSync(contractFileDestination)37 assert.isTrue(fileExists, "The 'contract example file' should be copied in deployment folder")38 });39 it('should have test folder and example file', async () => {40 let dirExists = fs.existsSync(testDir);41 assert.isTrue(dirExists, "The 'contracts' folder should exist.");42 let fileExists = fs.existsSync(testFileDestination);43 assert.isTrue(fileExists, "The 'test example file' should be copied in deployment folder")44 });45 it('should have deployment folder and example file', async () => {46 let dirExists = fs.existsSync(deploymentDir);47 let fileExists = fs.existsSync(deploymentFileDestination);48 assert.isTrue(dirExists, "The 'deployment' folder should exist.");49 assert.isTrue(fileExists, "The 'deployment example file' should be copied in deployment folder");50 });51 it('should throw error if contract example file already exists', async () => {52 await assert.isRejected(init.run(), contractError, "Expected throw not received");53 });54 it('should throw error if deployment example file already exists', async () => {55 fs.removeSync(contractsDir);56 await assert.isRejected(init.run(), deploymentError, "Expected throw not received");57 });58 it('should throw error if test example file already exists', async () => {59 fs.removeSync(contractsDir);60 fs.removeSync(deploymentDir);61 await assert.isRejected(init.run(), testError, "Expected throw not received");62 });63 it('should have .gitignore file', async () => {64 let gitignoreFile = fs.existsSync(gitignoreFileDestination);65 assert.isTrue(gitignoreFile, "The 'gitignoreFile' file should exist.");66 });67 it('should not override .gitignore file if it was already created', async () => {68 fs.removeSync(deploymentDir);69 fs.removeSync(testDir);70 fs.removeSync(contractsDir);71 fs.removeSync('./.gitignore');72 fs.writeFileSync('.gitignore', "myCustomFile");73 await init.run();74 let file = fs.readFileSync('.gitignore', "utf8");75 assert.notInclude('build')76 });77 after(async function () {78 fs.removeSync(deploymentDir);79 fs.removeSync(testDir);80 fs.removeSync(contractsDir);81 fs.removeSync(packageJsonDestination);82 fs.removeSync('./package-lock.json');83 fs.removeSync('./node_modules');84 fs.removeSync('./.gitignore');85 process.chdir(currentDir);86 });87});88describe('Init cli command with zkProof optional parameter', () => {89 let currentDir;90 before(async function () {91 currentDir = process.cwd();92 process.chdir('/tmp');93 });94 it('should execute init with optional parameter', async () => {95 await assert.isFulfilled(init.run(zkProofEnabled), 'It is successfully executed');96 })97 it('should have contracts folder and example file', async () => {98 let dirExists = fs.existsSync(contractsDir);99 assert.isTrue(dirExists, "The 'contracts' folder should exist.");100 let fileExists = fs.existsSync(contractFileDestination)101 assert.isTrue(fileExists, "The 'contract example file' should be copied in deployment folder")102 });103 it('should have test folder and example file', async () => {104 let dirExists = fs.existsSync(testDir);105 assert.isTrue(dirExists, "The 'contracts' folder should exist.");106 let fileExists = fs.existsSync(testFileDestination);107 assert.isTrue(fileExists, "The 'test example file' should be copied in deployment folder")108 });109 it('should have deployment folder and example file', async () => {110 let dirExists = fs.existsSync(deploymentDir);111 let fileExists = fs.existsSync(deploymentFileDestination);112 assert.isTrue(dirExists, "The 'deployment' folder should exist.");113 assert.isTrue(fileExists, "The 'deployment example file' should be copied in deployment folder");114 });115 it('should have deployment folder and example file', async () => {116 let dirExists = fs.existsSync(deploymentDir);117 let fileExists = fs.existsSync(deploymentFileDestination);118 assert.isTrue(dirExists, "The 'deployment' folder should exist.");119 assert.isTrue(fileExists, "The 'deployment example file' should be copied in deployment folder");120 });121 it('should have zero-knowledge-proof folder and example circuit file', async () => {122 let dirExists = fs.existsSync(zkProofDir);123 let fileExists = fs.existsSync(`${zkProofDir}/${circuitsDir}`);124 assert.isTrue(dirExists, "The 'zero-knowledge-proof' folder should exist.");125 assert.isTrue(fileExists, "The 'circuit file' should be copied in zero-knowledge-proof");126 });127 it('should have zero-knowledge-proof folder and example input file', async () => {128 let dirExists = fs.existsSync(zkProofDir);129 let fileExists = fs.existsSync(`${zkProofDir}/${inputParamsDir}`);130 assert.isTrue(dirExists, "The 'zero-knowledge-proof' folder should exist.");131 assert.isTrue(fileExists, "The 'input file' should be copied in zero-knowledge-proof");132 });133 it('should throw error if contract example file already exists', async () => {134 await assert.isRejected(init.run(zkProofEnabled), contractError, "Expected throw not received");135 });136 it('should throw error if deployment example file already exists', async () => {137 fs.removeSync(contractsDir);138 await assert.isRejected(init.run(zkProofEnabled), deploymentError, "Expected throw not received");139 });140 it('should throw error if test example file already exists', async () => {141 fs.removeSync(contractsDir);142 fs.removeSync(deploymentDir);143 await assert.isRejected(init.run(zkProofEnabled), testError, "Expected throw not received");144 });145 it('should throw error if zero-knowledge proof folder already exists', async () => {146 fs.removeSync(deploymentDir);147 fs.removeSync(testDir);148 fs.removeSync(contractsDir);149 await assert.isRejected(init.run(zkProofEnabled), zkProofError, "Expected throw not received");150 });151 it('should throw error if input file already exists', async () => {152 const expectedError = "input.json already exists in ./zero-knowledge-proof directory. You've probably already initialized etherlime for this project.";153 fs.removeSync(deploymentDir);154 fs.removeSync(testDir);155 fs.removeSync(contractsDir);156 fs.removeSync(`${zkProofDir}/${circuitsDir}`);157 await assert.isRejected(init.run(zkProofEnabled), expectedError, "Expected throw not received");158 });159 it('should have .gitignore file', async () => {160 let gitignoreFile = fs.existsSync(gitignoreFileDestination);161 assert.isTrue(gitignoreFile, "The 'gitignoreFile' file should exist.");162 });163 it('should not override .gitignore file if it was already created', async () => {164 fs.removeSync(deploymentDir);165 fs.removeSync(testDir);166 fs.removeSync(contractsDir);167 fs.removeSync('./.gitignore');168 fs.writeFileSync('.gitignore', "myCustomFile");169 await init.run();170 let file = fs.readFileSync('.gitignore', "utf8");171 assert.notInclude('build')172 });173 after(async function () {174 fs.removeSync(deploymentDir);175 fs.removeSync(testDir);176 fs.removeSync(contractsDir);177 fs.removeSync(packageJsonDestination);178 fs.removeSync(zkProofDir);179 fs.removeSync('./package-lock.json');180 fs.removeSync('./node_modules');181 fs.removeSync('./.gitignore');182 process.chdir(currentDir);183 });184});185describe('Init cli command with output optional parameter', () => {186 let currentDir;187 before(async function () {188 currentDir = process.cwd();189 process.chdir('/tmp');190 });191 it('should execute etherlime init with output param', async () => {192 const expectedOutput = 'Etherlime was successfully initialized!'193 const childResponse = await runCmdHandler(`etherlime init --output=normal`, expectedOutput);194 assert.include(childResponse.output, expectedOutput, 'The initialization process does not finish properly');195 });196 after(async function () {197 fs.removeSync(deploymentDir);198 fs.removeSync(testDir);199 fs.removeSync(contractsDir);200 fs.removeSync(packageJsonDestination);201 fs.removeSync('./package-lock.json');202 fs.removeSync('./node_modules');203 fs.removeSync('./.gitignore');204 process.chdir(currentDir);205 });...

Full Screen

Full Screen

file-tests.js

Source:file-tests.js Github

copy

Full Screen

...7 var content = "testWriteRead.txt\n";8 fs.write(path, content);9 assert.is(content, fs.read(path));10 } finally {11 fs.remove(path);12 }13}; 14exports.testOpenWriteReadWrongMode = function () {15 var path = "testOpenWriteReadWrongMode.txt";16 var content = "testOpenWriteReadWrongMode.txt\n";17 assert.throwsError(function () {18 fs.open(path).write(content).flush().close();19 fs.remove(path);20 });21};22exports.testOpenWriteFlushRead = function () {23 try {24 var path = "testOpenWriteRead.txt";25 var content = "testOpenWriteRead.txt\n";26 fs.open(path, 'w').write(content).flush().close();27 assert.is(content, fs.open(path).read());28 } finally {29 fs.remove(path);30 }31};32exports.testOpenWriteRead = function () {33 try {34 var path = "testOpenWriteRead.txt";35 var content = "testOpenWriteRead.txt\n";36 if (fs.exists(path)) fs.remove(path);37 fs.open(path, 'w').write(content);38 assert.is("", fs.open(path).read());39 } finally {40 fs.remove(path);41 }42};43exports.testOpenWriteReadFlushOnClose = function () {44 try {45 var path = "testOpenWriteRead.txt";46 var content = "testOpenWriteRead.txt\n";47 fs.open(path, 'w').write(content).close();48 assert.is(content, fs.open(path).read());49 } finally {50 fs.remove(path);51 }52};53exports.testPathWriteRead = function () {54 try {55 var path = "testOpenWriteRead.txt";56 var content = "testOpenWriteRead.txt\n";57 fs.path(path).write(content);58 assert.is(content, fs.path(path).read());59 } finally {60 fs.remove(path);61 }62};63exports.testNewPathWriteRead = function () {64 try {65 var path = "testNewPathWriteRead.txt";66 var content = "testNewPathWriteRead.txt\n";67 new fs.Path(path).write(content);68 assert.is(content, fs.Path(path).read());69 } finally {70 fs.remove(path);71 }72};73exports.testBigPathOpenWriteRead = function () {74 try {75 var path = "testBigPathWriteRead.txt";76 var content = "testBigPathWriteRead.txt\n";77 fs.Path(path).write(content);78 assert.is(content, fs.Path(path).read());79 } finally {80 fs.remove(path);81 }82};83exports.testLittlePathOpenWriteRead1 = function () {84 var path = "testLittlePathWriteRead.txt";85 var content = "testLittlePathWriteRead.txt\n";86 assert.throwsError(function () {87 fs.path(path).open().write(content).flush().close();88 fs.remove(path);89 });90};91exports.testLittlePathOpenWriteRead = function () {92 try {93 var path = "testLittlePathOpenWriteRead.txt";94 var content = "testLittlePathOpenWriteRead.txt\n";95 fs.path(path).open('w').write(content).flush().close();96 assert.is(content, fs.path(path).open().read());97 } finally {98 fs.remove(path);99 }100};101exports.testWriteReadNewlineNotEnforced = function() {102 try {103 var path = "testWriteReadNewlineNotEnforced.txt";104 var content = "testWriteReadNewlineNotEnforced.txt";105 fs.write(path, content);106 assert.is(content, fs.read(path));107 } finally {108 fs.remove(path);109 }110}; 111/*112exports.testWriteReadNewlineEnforced = function() {113 try {114 var path = "testWriteReadNewlineEnforced.txt";115 var content = "testWriteReadNewlineEnforced.txt";116 fs.write(path, content);117 assert.is(content + "\n", fs.read(path));118 } finally {119 fs.remove(path);120 }121};122*/123exports.testOverwriteFile = function() {124 var path = "testOverwriteFile.txt";125 var a = "hello world";126 var b = "hello";127 try {128 fs.write(path, a);129 assert.is(a, fs.read(path));130 assert.is(a.length, fs.size(path));131 fs.write(path, b);132 assert.is(b, fs.read(path));133 assert.is(b.length, fs.size(path));134 } finally {135 if (fs.isFile(path))136 fs.remove(path);137 }138}139exports.testWriteReadBinaryWrongMode = function () {140 var path = "testWriteReadBinaryModeWrongMode.txt";141 var content = "\0\0\0".toByteString("ascii");142 assert.throwsError(function () {143 fs.path(path).open('b').write(content).flush().close();144 fs.remove(path);145 });146};147exports.testWriteReadBinary = function () {148 try {149 var path = "testWriteReadBinary.txt";150 var content = "aaa".toByteString("ascii");151 fs.path(path).open('wb').write(content).flush().close();152 assert.eq(content, fs.path(path).open('b').read());153 } finally {154 fs.remove(path);155 }156};157exports.testWriteReadBinaryNulls = function () {158 try {159 var path = "testWriteReadBinaryNulls.txt";160 var content = "\0\0\0".toByteString("ascii");161 fs.path(path).open('wb').write(content).flush().close();162 assert.eq(content, fs.path(path).open('b').read());163 } finally {164 fs.remove(path);165 }166};167exports.testPrintRead = function () {168 try {169 var path = "testPrintRead.txt";170 fs.path(path).open('w').print("hello").print("world");171 assert.is("hello\nworld\n", fs.path(path).open().read());172 } finally {173 fs.remove(path);174 }175};176exports.testCopy = function () {177 try {178 fs.path("testCopyA.txt").write("testCopy\n").copy("testCopyB.txt");179 assert.is("testCopy\n", fs.read("testCopyB.txt"));180 } finally {181 fs.remove("testCopyA.txt");182 fs.remove("testCopyB.txt");183 }184};185exports.testCopyChain = function () {186 try {187 fs.path("testCopyA.txt").write("testCopy\n").copy("testCopyB.txt").copy("testCopyC.txt");188 assert.is("testCopy\n", fs.read("testCopyC.txt"));189 } finally {190 fs.remove("testCopyA.txt");191 fs.remove("testCopyB.txt");192 fs.remove("testCopyC.txt");193 }194};195exports.testMoveExists = function () {196 var testString = "testCopy";197 try {198 fs.path("testCopyA.txt").write(testString).move("testCopyB.txt");199 assert.isFalse(fs.exists("testCopyA.txt"));200 assert.isTrue(fs.exists("testCopyB.txt"));201 assert.is(fs.size("testCopyB.txt"), testString.length);202 } finally {203 if (fs.exists("testCopyA.txt"))204 fs.remove("testCopyA.txt");205 if (fs.exists("testCopyB.txt"))206 fs.remove("testCopyB.txt");207 }208};209exports.testsExists = function () {210 assert.isTrue(fs.exists(module.path));211 assert.isTrue(fs.path(module.path).exists());212};213exports.testsIsFile = function () {214 assert.isTrue(fs.isFile(module.path));215 assert.isTrue(fs.path(module.path).isFile());216};217exports.testsMkdir = function () {218 try {219 fs.mkdir('testMkdir');220 assert.isTrue(fs.exists('testMkdir'));...

Full Screen

Full Screen

shape.js

Source:shape.js Github

copy

Full Screen

1// const assert = require('chai').assert;2// let chai = require("chai");3// const fs = require("fs-extra")4// const runCmdHandler = require('../utils/spawn-child-process').runCmdHandler;5// let unexistingShape = 'sthUnexisting'6// describe('Shape cli command', () => {7// let currentDir;8// beforeEach(async function () {9// currentDir = process.cwd();10// process.chdir('/tmp');11// });12// it('should throw err if can not find a proper shape', async () => {13// let expectedOutput = 'Invalid shape'14// let childProcess = await runCmdHandler(`etherlime shape ${unexistingShape}`, expectedOutput)15// assert.include(childProcess, expectedOutput)16// })17// it('should shape new dApp with Angular front-end', async () => {18// let expectedOutput = 'Shaping finished successful';19// let childProcess = await runCmdHandler('etherlime shape angular', expectedOutput)20// assert.include(childProcess.output, expectedOutput)21// assert(fs.existsSync('./web'))22// });23// it('should shape new dApp with React front-end', async () => {24// let expectedOutput = 'Shaping finished successful';25// let childProcess = await runCmdHandler('etherlime shape react', expectedOutput)26// assert.include(childProcess.output, expectedOutput)27// assert(fs.existsSync('./web'))28// });29// it('should shape new dApp with Monoplasma shape', async () => {30// let expectedOutput = 'Shaping finished successful';31// let childProcess = await runCmdHandler('etherlime shape monoplasma', expectedOutput)32// assert.include(childProcess.output, expectedOutput)33// assert(fs.existsSync('./demo'))34// });35// it('should shape new Chainlink project', async () => {36// let expectedOutput = 'Shaping finished successful';37// let childProcess = await runCmdHandler('etherlime shape chainLink', expectedOutput)38// assert.include(childProcess.output, expectedOutput)39// })40// afterEach(async function () {41// fs.removeSync('./contracts')42// fs.removeSync('./deployment')43// fs.removeSync('./test')44// fs.removeSync('./web')45// fs.removeSync('./build')46// fs.removeSync('./config.json')47// fs.removeSync('./node_modules')48// fs.removeSync('./package.json')49// fs.removeSync('./package-lock.json');50// fs.removeSync('./README.md');51// fs.removeSync('./.git');52// fs.removeSync('./.etherlime-store');53// fs.removeSync('./.gitignore');54// fs.removeSync('./demo');55// fs.removeSync('./src');56// fs.removeSync('./start_operator.js');57// fs.removeSync('./start_validator.js');58// fs.removeSync('./strings');59// fs.removeSync('./99999_addresses.txt');60// fs.removeSync('./copy-abi-to-ui.js');61// fs.removeSync('./defaultServers.json');62// process.chdir(currentDir);63// });...

Full Screen

Full Screen

replace-redux-files-to-mobx.js

Source:replace-redux-files-to-mobx.js Github

copy

Full Screen

1const path = require('path')2const mobxTemplatePath = path.join(__dirname, '.mobxTemplate')3module.exports = function(folderPath) {4 // 删除/修改入口文件中redux相关的模块5 this.fs.removeSync(path.join(folderPath, 'src/configureStore.ts'))6 this.fs.removeSync(path.join(folderPath, 'src/reducers.ts'))7 this.fs.copySync(8 path.join(mobxTemplatePath, 'app.tsx'),9 path.join(folderPath, 'src/app.tsx')10 )11 // 添加store12 this.fs.copySync(13 path.join(mobxTemplatePath, 'store'),14 path.join(folderPath, 'src/store')15 )16 // 删除/修改util中redux相关的模块17 const utilPath = path.join(folderPath, 'src/util')18 this.fs.removeSync(path.join(utilPath, 'reducerInjectors.ts'))19 this.fs.removeSync(path.join(utilPath, 'sagaInjectors.ts'))20 this.fs.removeSync(path.join(utilPath, 'constants.ts'))21 // 删除typings中redux相关的模块22 const typingsPath = path.join(folderPath, 'typings')23 this.fs.removeSync(path.join(typingsPath, 'redux-store.shim.d.ts'))24 this.fs.removeSync(path.join(typingsPath, 'redux.shim.d.ts'))25 // 添加router.d.ts到typings26 this.fs.copySync(27 path.join(mobxTemplatePath, 'typings/router.d.ts'),28 path.join(typingsPath, 'router.d.ts')29 )30 // 删除/修改components中redux相关的组件31 const componentsPath = path.join(folderPath, 'src/components')32 this.fs.removeSync(path.join(componentsPath, 'ReducerInjector/'))33 this.fs.removeSync(path.join(componentsPath, 'SagaInjector'))34 // 删除/修改containers中redux相关的组件35 const containersPath = path.join(folderPath, 'src/containers')36 this.fs.emptyDirSync(containersPath)37 this.fs.copySync(path.join(mobxTemplatePath, 'containers'), containersPath)...

Full Screen

Full Screen

view.mocha.js

Source:view.mocha.js Github

copy

Full Screen

1'use strict';2const { fs, runCmdSync, _ } = require('rk-utils');3const path = require('path');4const winston = require('winston');5const WORKING_FOLDER = path.resolve(__dirname, 'view');6const OOLONG_CLI = 'node ../../lib/cli/oolong.js';7describe.skip('e2e:view', function () {8 let logger = winston.createLogger({9 "level": "debug",10 "transports": [11 new winston.transports.Console({ 12 "format": winston.format.combine(winston.format.colorize(), winston.format.simple())13 })14 ]15 });16 let cfg;17 before(function () { 18 process.chdir(WORKING_FOLDER);19 fs.removeSync(path.join(WORKING_FOLDER, 'models'));20 fs.removeSync(path.join(WORKING_FOLDER, 'scripts'));21 //fs.removeSync(path.join(WORKING_FOLDER, 'resources'));22 cfg = fs.readJsonSync('./oolong.json', 'utf8');23 });24 after(function () {25 fs.removeSync(path.join(WORKING_FOLDER, 'oolong-cli.log'));26 fs.removeSync(path.join(WORKING_FOLDER, 'models'));27 fs.removeSync(path.join(WORKING_FOLDER, 'scripts'));28 //fs.removeSync(path.join(WORKING_FOLDER, 'resources'));29 });30 it('build', function () {31 let output = runCmdSync(OOLONG_CLI + ' build -c oolong.json');32 33 output.should.match(/Generated entity model/);34 });35 it('migrate', function () {36 let output = runCmdSync(OOLONG_CLI + ' migrate -c oolong.json -r');37 38 output.should.match(/Database scripts ".+?" run successfully/);39 }); 40 ...

Full Screen

Full Screen

build.js

Source:build.js Github

copy

Full Screen

1const program = require('commander');2const path = require('path');3const fs = require('fs-extra');4const shelljs = require('shelljs');5const cwd = process.cwd();6/* eslint prefer-arrow-callback:0 */7/* eslint no-console:0 */8module.exports = function() {9 const scaffoldDir = path.join(cwd, './dist');10 const siteDir = path.join(cwd, '../_scaffold_site');11 const utilsDir = `${cwd}/src/utils`;12 process.on('exit', function() {});13 process.on('SIGINT', function() {14 fs.copySync(`${utilsDir}/request-temp.js`, `${utilsDir}/request.js`);15 fs.removeSync(`${utilsDir}/request-temp.js`);16 fs.removeSync(`${cwd}/src/.roadhogrc.mock.js`);17 fs.removeSync(`${cwd}/src/mock`);18 if (program.runningCommand) {19 program.runningCommand.kill('SIGKILL');20 }21 process.exit(0);22 });23 shelljs.exec('roadhog-api-doc build', function(code, stdout, stderr) {24 try {25 // clean26 fs.copySync(`${utilsDir}/request-temp.js`, `${utilsDir}/request.js`);27 fs.removeSync(`${utilsDir}/request-temp.js`);28 fs.removeSync(`${cwd}/src/.roadhogrc.mock.js`);29 fs.removeSync(`${cwd}/src/mock`);30 /* eslint no-empty: 0 */31 } catch (e) {32 } finally {33 try {34 fs.ensureDirSync(siteDir);35 // move36 fs.copySync(scaffoldDir, siteDir);37 } catch (e) {38 /* eslint no-unsafe-finally: 0 */39 throw new Error(e);40 }41 }42 if (!stderr) {43 console.log('build static success');44 }45 });...

Full Screen

Full Screen

copy_inuitcss.js

Source:copy_inuitcss.js Github

copy

Full Screen

1const fs = require("fs-extra");2// copy directory, even if it has subdirectories or files3fs.copySync('./node_modules/inuitcss', './docs/_sass/inuitcss');4fs.removeSync('./docs/_sass/inuitcss/.stylelintrc');5fs.removeSync('./docs/_sass/inuitcss/CHANGELOG.md');6fs.removeSync('./docs/_sass/inuitcss/circle.yml');7fs.removeSync('./docs/_sass/inuitcss/example.main.scss');8fs.removeSync('./docs/_sass/inuitcss/package.json');9fs.removeSync('./docs/_sass/inuitcss/README.md');10fs.removeSync('./docs/_sass/inuitcss/components');11fs.removeSync('./docs/_sass/inuitcss/settings/_example.settings.config.scss');12fs.removeSync('./docs/_sass/inuitcss/settings/_example.settings.global.scss');13fs.copySync('./node_modules/sass-mq', './docs/_sass/sass-mq');14fs.removeSync('./docs/_sass/sass-mq/package.json');...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { remove } from 'fs-extra'2describe('My First Test', function() {3 it('Does not do much!', function() {4 remove('cypress/fixtures/test.txt')5 })6})7I am trying to use fs-extra remove method in Cypress. I have installed fs-extra package and imported remove method. But when I run my test, I get the following error:8TypeError: (0 , _fsExtra.remove) is not a function9I have tried to use fs-extra remove method in Cypress. I have installed fs-extra package and imported remove method. But when I run my test, I get the following error:10TypeError: (0 , _fsExtra.remove) is not a function11I am trying to use fs-extra remove method in Cypress. I have installed fs-extra package and imported remove method. But when I run my test, I get the following error:12TypeError: (0 , _fsExtra.remove) is not a function13I am trying to use fs-extra remove method in Cypress. I have installed fs-extra package and imported remove method. But when I run my test, I get the following error:14TypeError: (0 , _fsExtra.remove) is not a function15I am trying to use fs-extra remove method in Cypress. I have installed fs-extra package and imported remove method. But when I run my test, I get the following error:16TypeError: (0 , _fsExtra.remove) is not a function17I am trying to use fs-extra remove method in Cypress. I have installed fs-extra package and imported remove method. But when I run my test, I get the following error:18TypeError: (0 , _fsExtra.remove) is not a function19I am trying to use fs-extra remove method in Cypress. I have installed fs-extra package and imported remove method. But when I run my test, I get the following error:20TypeError: (0 , _fsExtra.remove) is not a function21I am trying to use fs-extra remove method in Cypress. I have installed fs-extra package and imported remove method. But when I run my test, I get the following error:22TypeError: (0 , _fsExtra.remove) is not a function23I am trying to use fs-extra remove method in Cypress. I have installed fs-extra package and imported remove method. But when I run my test, I get the following error:24TypeError: (0 ,

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.task('remove', { path: 'cypress/screenshots' });2fs.remove('cypress/screenshots');3fs.remove('cypress/screenshots', (err) => {4 if (err) throw err;5});6fs.remove('cypress/screenshots', (err) => {7 if (err) throw err;8 console.log('cypress/screenshots removed!');9});10fs.remove('cypress/screenshots', (err) => {11 if (err) throw err;12 console.log('cypress/screenshots removed!');13 fs.remove('cypress/videos', (err) => {14 if (err) throw err;15 console.log('cypress/videos removed!');16 });17});18fs.remove('cypress/screenshots', (err) => {19 if (err) throw err;20 console.log('cypress/screenshots removed!');21 fs.remove('cypress/videos', (err) => {22 if (err) throw err;23 console.log('cypress/videos removed!');24 fs.remove('cypress/support', (err) => {25 if (err) throw err;26 console.log('cypress/support removed!');27 });28 });29});30fs.remove('cypress/screenshots', (err) => {31 if (err) throw err;32 console.log('cypress/screenshots removed!');33 fs.remove('cypress/videos', (err) => {34 if (err) throw err;35 console.log('cypress/videos removed!');36 fs.remove('cypress/support', (err) => {37 if (err) throw err;38 console.log('cypress/support removed!');39 fs.remove('cypress/integration', (err) => {40 if (err) throw err;41 console.log('cypress/integration removed!');42 });43 });44 });45});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Testing fs', function() {2 it('removing file', function() {3 cy.task('remove', 'test.js');4 });5});6module.exports = (on, config) => {7 on('task', {8 remove: require('cypress-fs').remove,9 });10};

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test', () => {2 it('should remove a directory', () => {3 cy.task('remove', 'cypress/screenshots')4 })5})6pipeline {7 stages {8 stage('Test') {9 steps {10 }11 }12 }13}14[Pipeline] }15[Pipeline] }16pipeline {17 stages {18 stage('Test') {19 steps {20 nodejs {21 }22 }23 }24 }25}26pipeline {27 stages {28 stage('Test') {29 steps {30 }31 }32 }33}34[Pipeline] }35[Pipeline] }

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', () => {2 it('Does not do much!', () => {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful