How to use cypress.run method in Cypress

Best JavaScript code snippet using cypress

cypress.builder.spec.js

Source:cypress.builder.spec.js Github

copy

Full Screen

1"use strict";2Object.defineProperty(exports, "__esModule", { value: true });3var cypress_builder_1 = require("./cypress.builder");4var testing_1 = require("@angular-devkit/architect/testing");5var core_1 = require("@angular-devkit/core");6var events_1 = require("events");7var child_process = require("child_process");8var path = require("path");9var fsUtility = require("@angular-devkit/schematics/tools/file-system-utility");10var fsExtras = require("fs-extra");11var Cypress = require('cypress');12describe('Cypress builder', function () {13 var builder;14 var cypressBuilderOptions = {15 cypressConfig: 'apps/my-app-e2e/cypress.json',16 parallel: false,17 tsConfig: 'apps/my-app-e2e/tsconfig.json',18 devServerTarget: 'my-app:serve',19 headless: true,20 exit: true,21 record: false,22 baseUrl: undefined,23 watch: false24 };25 beforeEach(function () {26 builder = new cypress_builder_1.default({27 host: {},28 logger: new testing_1.TestLogger('test'),29 workspace: {30 root: '/root'31 },32 architect: {}33 });34 });35 describe('run', function () {36 it('should call `fork.child_process` with the tsc command', function () {37 spyOn(fsUtility, 'readFile').and.returnValue(JSON.stringify({38 compilerOptions: { outDir: '../../dist/out-tsc/apps/my-app-e2e/src' }39 }));40 var fakeEventEmitter = new events_1.EventEmitter();41 var fork = spyOn(child_process, 'fork').and.returnValue(fakeEventEmitter);42 builder43 .run({44 root: core_1.normalize('/root'),45 projectType: 'application',46 builder: '@nrwl/builders:cypress',47 options: cypressBuilderOptions48 })49 .subscribe(function () {50 expect(fork).toHaveBeenCalledWith('/root/node_modules/.bin/tsc', cypressBuilderOptions.tsConfig, { stdio: [0, 1, 2] });51 });52 fakeEventEmitter.emit('exit');53 });54 it('should call `Cypress.run` if headless mode is `true`', function () {55 spyOn(fsUtility, 'readFile').and.returnValue(JSON.stringify({56 compilerOptions: { outDir: '../../dist/out-tsc/apps/my-app-e2e/src' }57 }));58 var fakeEventEmitter = new events_1.EventEmitter();59 spyOn(child_process, 'fork').and.returnValue(fakeEventEmitter);60 var cypressRun = spyOn(Cypress, 'run');61 var cypressOpen = spyOn(Cypress, 'open');62 builder63 .run({64 root: core_1.normalize('/root'),65 projectType: 'application',66 builder: '@nrwl/builders:cypress',67 options: cypressBuilderOptions68 })69 .subscribe(function () {70 expect(cypressRun).toHaveBeenCalledWith({71 config: { baseUrl: 'http://localhost:4200' },72 project: path.dirname(cypressBuilderOptions.cypressConfig)73 });74 expect(cypressOpen).not.toHaveBeenCalled();75 });76 fakeEventEmitter.emit('exit'); // Passing tsc command77 });78 it('should call `Cypress.open` if headless mode is `false`', function () {79 spyOn(fsUtility, 'readFile').and.returnValue(JSON.stringify({80 compilerOptions: { outDir: '../../dist/out-tsc/apps/my-app-e2e/src' }81 }));82 var fakeEventEmitter = new events_1.EventEmitter();83 spyOn(child_process, 'fork').and.returnValue(fakeEventEmitter);84 var cypressRun = spyOn(Cypress, 'run');85 var cypressOpen = spyOn(Cypress, 'open');86 builder87 .run({88 root: core_1.normalize('/root'),89 projectType: 'application',90 builder: '@nrwl/builders:cypress',91 options: Object.assign(cypressBuilderOptions, { headless: false })92 })93 .subscribe(function () {94 expect(cypressOpen).toHaveBeenCalledWith({95 config: { baseUrl: 'http://localhost:4200' },96 project: path.dirname(cypressBuilderOptions.cypressConfig)97 });98 expect(cypressRun).not.toHaveBeenCalled();99 });100 fakeEventEmitter.emit('exit'); // Passing tsc command101 });102 it('should call `Cypress.run` with provided baseUrl', function () {103 spyOn(fsUtility, 'readFile').and.returnValue(JSON.stringify({104 compilerOptions: { outDir: '../../dist/out-tsc/apps/my-app-e2e/src' }105 }));106 var fakeEventEmitter = new events_1.EventEmitter();107 spyOn(child_process, 'fork').and.returnValue(fakeEventEmitter);108 var cypressRun = spyOn(Cypress, 'run');109 builder110 .run({111 root: core_1.normalize('/root'),112 projectType: 'application',113 builder: '@nrwl/builders:cypress',114 options: Object.assign(cypressBuilderOptions, {115 baseUrl: 'http://my-distant-host.com'116 })117 })118 .subscribe(function () {119 expect(cypressRun).toHaveBeenCalledWith({120 config: { baseUrl: 'http://my-distant-host.com' },121 project: path.dirname(cypressBuilderOptions.cypressConfig)122 });123 });124 fakeEventEmitter.emit('exit'); // Passing tsc command125 });126 it('should call `Cypress.run` with provided browser', function () {127 spyOn(fsUtility, 'readFile').and.returnValue(JSON.stringify({128 compilerOptions: { outDir: '../../dist/out-tsc/apps/my-app-e2e/src' }129 }));130 var fakeEventEmitter = new events_1.EventEmitter();131 spyOn(child_process, 'fork').and.returnValue(fakeEventEmitter);132 var cypressRun = spyOn(Cypress, 'run');133 builder134 .run({135 root: core_1.normalize('/root'),136 projectType: 'application',137 builder: '@nrwl/builders:cypress',138 options: Object.assign(cypressBuilderOptions, {139 browser: 'chrome'140 })141 })142 .subscribe(function () {143 expect(cypressRun).toHaveBeenCalledWith({144 config: { browser: 'chrome' },145 project: path.dirname(cypressBuilderOptions.cypressConfig)146 });147 });148 fakeEventEmitter.emit('exit'); // Passing tsc command149 });150 it('should call `Cypress.run` without baseUrl nor dev server target value', function () {151 spyOn(fsUtility, 'readFile').and.returnValue(JSON.stringify({152 compilerOptions: { outDir: '../../dist/out-tsc/apps/my-app-e2e/src' }153 }));154 var fakeEventEmitter = new events_1.EventEmitter();155 spyOn(child_process, 'fork').and.returnValue(fakeEventEmitter);156 var cypressRun = spyOn(Cypress, 'run');157 builder158 .run({159 root: core_1.normalize('/root'),160 projectType: 'application',161 builder: '@nrwl/builders:cypress',162 options: {163 cypressConfig: 'apps/my-app-e2e/cypress.json',164 tsConfig: 'apps/my-app-e2e/tsconfig.json',165 devServerTarget: undefined,166 headless: true,167 exit: true,168 parallel: false,169 record: false,170 baseUrl: undefined,171 watch: false172 }173 })174 .subscribe(function () {175 expect(cypressRun).toHaveBeenCalledWith({176 project: path.dirname(cypressBuilderOptions.cypressConfig)177 });178 });179 fakeEventEmitter.emit('exit'); // Passing tsc command180 });181 it('should copy fixtures folder to out-dir', function () {182 spyOn(fsUtility, 'readFile').and.callFake(function (path) {183 return path.endsWith('tsconfig.e2e.json')184 ? JSON.stringify({185 compilerOptions: {186 outDir: '../../dist/out-tsc/apps/my-app-e2e/src'187 }188 })189 : JSON.stringify({190 fixturesFolder: '../../dist/out-tsc/apps/my-app-e2e/src/fixtures'191 });192 });193 var fakeEventEmitter = new events_1.EventEmitter();194 spyOn(child_process, 'fork').and.returnValue(fakeEventEmitter);195 spyOn(Cypress, 'run');196 spyOn(fsExtras, 'copySync');197 builder198 .run({199 root: core_1.normalize('/root'),200 projectType: 'application',201 builder: '@nrwl/builders:cypress',202 options: {203 cypressConfig: 'apps/my-app-e2e/cypress.json',204 tsConfig: 'apps/my-app-e2e/tsconfig.e2e.json',205 devServerTarget: undefined,206 headless: true,207 exit: true,208 parallel: false,209 record: false,210 baseUrl: undefined,211 watch: false212 }213 })214 .subscribe(function () {215 expect(fsExtras.copySync).toHaveBeenCalledWith('apps/my-app-e2e/src/fixtures', 'dist/out-tsc/my-app-e2e/src/fixtures');216 });217 fakeEventEmitter.emit('exit'); // Passing tsc command218 });219 it('should not copy fixtures folder if they are not defined in the cypress config', function () {220 spyOn(fsUtility, 'readFile').and.callFake(function (path) {221 return path.endsWith('tsconfig.e2e.json')222 ? JSON.stringify({223 compilerOptions: {224 outDir: '../../dist/out-tsc/apps/my-app-e2e/src'225 }226 })227 : JSON.stringify({});228 });229 var fakeEventEmitter = new events_1.EventEmitter();230 spyOn(child_process, 'fork').and.returnValue(fakeEventEmitter);231 spyOn(Cypress, 'run');232 spyOn(fsExtras, 'copySync');233 builder234 .run({235 root: core_1.normalize('/root'),236 projectType: 'application',237 builder: '@nrwl/builders:cypress',238 options: {239 cypressConfig: 'apps/my-app-e2e/cypress.json',240 tsConfig: 'apps/my-app-e2e/tsconfig.e2e.json',241 devServerTarget: undefined,242 headless: true,243 exit: true,244 parallel: false,245 record: false,246 baseUrl: undefined,247 watch: false248 }249 })250 .subscribe(function () {251 expect(fsExtras.copySync).not.toHaveBeenCalled();252 });253 fakeEventEmitter.emit('exit'); // Passing tsc command254 });255 });...

Full Screen

Full Screen

package-scripts.js

Source:package-scripts.js Github

copy

Full Screen

1const fs = require('fs');2const gulp = require('gulp');3const log = require('fancy-log');4const colors = require('ansi-colors');5const isNil = require('lodash/isNil');6const projectPath = require('../../lib/project-path');7const packageScriptsTask = cb => {8 const pkgFile = `${projectPath(9 global.SETTINGS_CONFIG.root.path10 )}/package.json`;11 fs.readFile(pkgFile, {encoding: 'utf8'}, (readError, data) => {12 if (readError) {13 // eslint-disable-next-line no-console14 console.log(readError);15 }16 const jsonData = JSON.parse(data);17 const startScript =18 'NODE_ENV=development BABEL_ENV=development ACE_NPM_EVENT=start ace';19 const startSSRScript =20 'NODE_ENV=development BABEL_ENV=development ACE_NPM_EVENT=start ACE_ENVIRONMENT=server ace -- ssrDev';21 const testScript =22 'NODE_ENV=test BABEL_ENV=test ACE_NPM_EVENT=test ace -- test & wait-on http://localhost:3000 && npm run cypress:open';23 const testSSRScript =24 'NODE_ENV=test BABEL_ENV=test ACE_NPM_EVENT=test ACE_ENVIRONMENT=server ace -- ssrTest & wait-on http://localhost:3000 && npm run cypress:open';25 const buildScript =26 'NODE_ENV=production BABEL_ENV=production ACE_NPM_EVENT=build ace -- production';27 const buildSSRScript =28 'NODE_ENV=production BABEL_ENV=production ACE_NPM_EVENT=build ACE_ENVIRONMENT=server ace -- ssrProduction';29 const serverScript =30 'NODE_ENV=production BABEL_ENV=production ACE_NPM_EVENT=server ace -- serverSSR';31 const cypressOpenScript =32 'ace -- generateWebpackSettings && cypress open';33 const cypressRunScript =34 'ace -- generateWebpackSettings && cypress run';35 const deploySandboxScript =36 'npm run build && ACE_DEPLOY_TYPE=sandbox ace -- deploy';37 const deployStagingScript =38 'npm run build && ACE_DEPLOY_TYPE=staging ace -- deploy';39 const deployProductionScript =40 'npm run build && ACE_DEPLOY_TYPE=production ace -- deploy';41 let msg = 'You have existing scripts that ACE will overwrite.';42 let willOverride = false;43 if (44 !isNil(jsonData.scripts.start) &&45 jsonData.scripts.start !== startScript46 ) {47 msg += `\nCurrent "start" script will be saved as "start-backup".`;48 jsonData.scripts['start-backup'] = jsonData.scripts.start;49 willOverride = true;50 }51 jsonData.scripts.start = startScript;52 if (53 !isNil(jsonData.scripts['start:ssr']) &&54 jsonData.scripts['start:ssr'] !== startSSRScript55 ) {56 msg += `\nCurrent "start:ssr" script will be saved as "start:ssr-backup".`;57 jsonData.scripts['start:ssr-backup'] =58 jsonData.scripts['start:ssr'];59 willOverride = true;60 }61 jsonData.scripts['start:ssr'] = startSSRScript;62 if (63 !isNil(jsonData.scripts.test) &&64 jsonData.scripts.test !== testScript65 ) {66 msg += `\nCurrent "test" script will be saved as "test-backup".`;67 jsonData.scripts['test-backup'] = jsonData.scripts.test;68 willOverride = true;69 }70 jsonData.scripts.test = testScript;71 if (72 !isNil(jsonData.scripts['test:ssr']) &&73 jsonData.scripts['test:ssr'] !== testSSRScript74 ) {75 msg += `\nCurrent "test:ssr" script will be saved as "test:ssr-backup".`;76 jsonData.scripts['test:ssr-backup'] = jsonData.scripts['test:ssr'];77 willOverride = true;78 }79 jsonData.scripts['test:ssr'] = testSSRScript;80 if (81 !isNil(jsonData.scripts.build) &&82 jsonData.scripts.build !== buildScript83 ) {84 msg += `\nCurrent "build" script will be saved as "build-backup".`;85 jsonData.scripts['build-backup'] = jsonData.scripts.build;86 willOverride = true;87 }88 jsonData.scripts.build = buildScript;89 if (90 !isNil(jsonData.scripts['build:ssr']) &&91 jsonData.scripts['build:ssr'] !== buildSSRScript92 ) {93 msg += `\nCurrent "build:ssr" script will be saved as "build:ssr-backup".`;94 jsonData.scripts['build:ssr-backup'] =95 jsonData.scripts['build:ssr'];96 willOverride = true;97 }98 jsonData.scripts['build:ssr'] = buildSSRScript;99 if (100 !isNil(jsonData.scripts.server) &&101 jsonData.scripts.server !== serverScript102 ) {103 msg += `\nCurrent "server" script will be saved as "server-backup".`;104 jsonData.scripts['server-backup'] = jsonData.scripts.server;105 willOverride = true;106 }107 jsonData.scripts.server = serverScript;108 if (109 !isNil(jsonData.scripts['cypress:open']) &&110 jsonData.scripts['cypress:open'] !== cypressOpenScript111 ) {112 msg += `\nCurrent "cypress:open" script will be saved as "cypress:open-backup".`;113 jsonData.scripts['cypress:open-backup'] =114 jsonData.scripts.cypressOpenScript;115 willOverride = true;116 }117 jsonData.scripts['cypress:open'] = cypressOpenScript;118 if (119 !isNil(jsonData.scripts['cypress:run']) &&120 jsonData.scripts['cypress:run'] !== cypressRunScript121 ) {122 msg += `\nCurrent "cypress:run" script will be saved as "cypress:run-backup".`;123 jsonData.scripts['cypress:run-backup'] =124 jsonData.scripts.cypressRunScript;125 willOverride = true;126 }127 jsonData.scripts['cypress:run'] = cypressRunScript;128 if (129 !isNil(jsonData.scripts['deploy:sandbox']) &&130 jsonData.scripts['deploy:sandbox'] !== deploySandboxScript131 ) {132 msg += `\nCurrent "deploy:sandbox" script will be saved as "deploy:sandbox-backup".`;133 jsonData.scripts['deploy:sandbox-backup'] =134 jsonData.scripts['deploy:sandbox'];135 willOverride = true;136 }137 jsonData.scripts['deploy:sandbox'] = deploySandboxScript;138 if (139 !isNil(jsonData.scripts['deploy:staging']) &&140 jsonData.scripts['deploy:staging'] !== deployStagingScript141 ) {142 msg += `\nCurrent "deploy:staging" script will be saved as "deploy:staging-backup".`;143 jsonData.scripts['deploy:staging-backup'] =144 jsonData.scripts['deploy:staging'];145 willOverride = true;146 }147 jsonData.scripts['deploy:staging'] = deployStagingScript;148 if (149 !isNil(jsonData.scripts['deploy:production']) &&150 jsonData.scripts['deploy:production'] !== deployProductionScript151 ) {152 msg += `\nCurrent "deploy:production" script will be saved as "deploy:production-backup".`;153 jsonData.scripts['deploy:production-backup'] =154 jsonData.scripts['deploy:production'];155 willOverride = true;156 }157 jsonData.scripts['deploy:production'] = deployProductionScript;158 if (willOverride) {159 log(colors.red(msg));160 }161 fs.writeFile(pkgFile, JSON.stringify(jsonData, null, 2), writeError => {162 if (writeError) {163 // eslint-disable-next-line no-console164 return console.log(writeError);165 }166 cb();167 });168 });169};...

Full Screen

Full Screen

verify_spec.js

Source:verify_spec.js Github

copy

Full Screen

1exports['verbose stdout output 1'] = `2It looks like this is your first time using Cypress: 1.2.33 ✔ Verified Cypress! /cache/Cypress/1.2.3/Cypress.app4Opening Cypress...5`6exports['no version of Cypress installed 1'] = `7Error: No version of Cypress is installed in: /cache/Cypress/1.2.3/Cypress.app8Please reinstall Cypress by running: cypress install9----------10Cypress executable not found at: /cache/Cypress/1.2.3/Cypress.app/Contents/MacOS/Cypress11----------12Platform: darwin (Foo-OsVersion)13Cypress Version: 1.2.314`15exports['warning installed version does not match verified version 1'] = `16Found binary version bloop installed in: /cache/Cypress/1.2.3/Cypress.app17⚠ Warning: Binary version bloop does not match the expected package version 1.2.318 These versions may not work properly together.19`20exports['executable cannot be found 1'] = `21Error: No version of Cypress is installed in: /cache/Cypress/1.2.3/Cypress.app22Please reinstall Cypress by running: cypress install23----------24Cypress executable not found at: /cache/Cypress/1.2.3/Cypress.app/Contents/MacOS/Cypress25----------26Platform: darwin (Foo-OsVersion)27Cypress Version: 1.2.328`29exports['verification with executable 1'] = `30It looks like this is your first time using Cypress: 1.2.331 ✔ Verified Cypress! /cache/Cypress/1.2.3/Cypress.app32Opening Cypress...33`34exports['fails verifying Cypress 1'] = `35It looks like this is your first time using Cypress: 1.2.336 ✖ Verifying Cypress can run /cache/Cypress/1.2.3/Cypress.app37STRIPPED38Error: Cypress failed to start.39This is usually caused by a missing library or dependency.40The error below should indicate which dependency is missing.41https://on.cypress.io/required-dependencies42If you are using Docker, we provide containers with all required dependencies installed.43----------44an error about dependencies45----------46Platform: darwin (Foo-OsVersion)47Cypress Version: 1.2.348`49exports['current version has not been verified 1'] = `50It looks like this is your first time using Cypress: 1.2.351 ✔ Verified Cypress! /cache/Cypress/1.2.3/Cypress.app52Opening Cypress...53`54exports['no welcome message 1'] = `55Found binary version 7.8.9 installed in: /cache/Cypress/1.2.3/Cypress.app56⚠ Warning: Binary version 7.8.9 does not match the expected package version 1.2.357 These versions may not work properly together.58`59exports['xvfb fails 1'] = `60It looks like this is your first time using Cypress: 1.2.361 ✖ Verifying Cypress can run /cache/Cypress/1.2.3/Cypress.app62STRIPPED63Error: Your system is missing the dependency: XVFB64Install XVFB and run Cypress again.65Read our documentation on dependencies for more information:66https://on.cypress.io/required-dependencies67If you are using Docker, we provide containers with all required dependencies installed.68----------69Caught error trying to run XVFB: "test without xvfb"70----------71Platform: darwin (Foo-OsVersion)72Cypress Version: 1.2.373`74exports['verifying in ci 1'] = `75It looks like this is your first time using Cypress: 1.2.376[xx:xx:xx] Verifying Cypress can run /cache/Cypress/1.2.3/Cypress.app [started]77[xx:xx:xx] Verifying Cypress can run /cache/Cypress/1.2.3/Cypress.app [completed]78Opening Cypress...79`80exports['valid CYPRESS_RUN_BINARY 1'] = `81Note: You have set the environment variable: CYPRESS_RUN_BINARY=/custom/Contents/MacOS/Cypress:82 This overrides the default Cypress binary path used.83It looks like this is your first time using Cypress: 1.2.384 ✔ Verified Cypress! /real/custom85Opening Cypress...86`87exports['darwin: error when invalid CYPRESS_RUN_BINARY 1'] = `88Note: You have set the environment variable: CYPRESS_RUN_BINARY=/custom/:89 This overrides the default Cypress binary path used.90Error: Could not run binary set by environment variable CYPRESS_RUN_BINARY=/custom/91Ensure the environment variable is a path to the Cypress binary, matching **/Contents/MacOS/Cypress92----------93ENOENT: no such file or directory, stat '/custom/'94----------95Platform: darwin (Foo-OsVersion)96Cypress Version: 1.2.397`98exports['linux: error when invalid CYPRESS_RUN_BINARY 1'] = `99Note: You have set the environment variable: CYPRESS_RUN_BINARY=/custom/:100 This overrides the default Cypress binary path used.101Error: Could not run binary set by environment variable CYPRESS_RUN_BINARY=/custom/102Ensure the environment variable is a path to the Cypress binary, matching **/Cypress103----------104ENOENT: no such file or directory, stat '/custom/'105----------106Platform: linux (Foo-OsVersion)107Cypress Version: 1.2.3108`109exports['win32: error when invalid CYPRESS_RUN_BINARY 1'] = `110Note: You have set the environment variable: CYPRESS_RUN_BINARY=/custom/:111 This overrides the default Cypress binary path used.112Error: Could not run binary set by environment variable CYPRESS_RUN_BINARY=/custom/113Ensure the environment variable is a path to the Cypress binary, matching **/Cypress.exe114----------115ENOENT: no such file or directory, stat '/custom/'116----------117Platform: win32 (Foo-OsVersion)118Cypress Version: 1.2.3119`120exports['silent verify 1'] = `121[no output]122`123exports['no Cypress executable 1'] = `124Error: No version of Cypress is installed in: /cache/Cypress/1.2.3/Cypress.app125Please reinstall Cypress by running: cypress install126----------127Cypress executable not found at: /cache/Cypress/1.2.3/Cypress.app/Contents/MacOS/Cypress128----------129Platform: darwin (Foo-OsVersion)130Cypress Version: 1.2.3131`132exports['Cypress non-executable permissions 1'] = `133Error: Cypress cannot run because the binary does not have executable permissions: /cache/Cypress/1.2.3/Cypress.app/Contents/MacOS/Cypress134Reasons this may happen:135- node was installed as 'root' or with 'sudo'136- the cypress npm package as 'root' or with 'sudo'137Please check that you have the appropriate user permissions.138----------139Platform: darwin (Foo-OsVersion)140Cypress Version: 1.2.3141`142exports['different version installed 1'] = `143Found binary version 7.8.9 installed in: /cache/Cypress/1.2.3/Cypress.app144⚠ Warning: Binary version 7.8.9 does not match the expected package version 1.2.3145 These versions may not work properly together.146It looks like this is your first time using Cypress: 7.8.9147 ✔ Verified Cypress! /cache/Cypress/1.2.3/Cypress.app148Opening Cypress...149`150exports['fails with no stderr 1'] = `151Error: Cypress failed to start.152This is usually caused by a missing library or dependency.153The error below should indicate which dependency is missing.154https://on.cypress.io/required-dependencies155If you are using Docker, we provide containers with all required dependencies installed.156----------157Error: EPERM NOT PERMITTED158----------159Platform: darwin (Foo-OsVersion)160Cypress Version: 1.2.3161`162exports['error binary not found in ci 1'] = `163Error: The cypress npm package is installed, but the Cypress binary is missing.164We expected the binary to be installed here: /cache/Cypress/1.2.3/Cypress.app/Contents/MacOS/Cypress165Reasons it may be missing:166- You're caching 'node_modules' but are not caching this path: /cache/Cypress167- You ran 'npm install' at an earlier build step but did not persist: /cache/Cypress168Properly caching the binary will fix this error and avoid downloading and unzipping Cypress.169Alternatively, you can run 'cypress install' to download the binary again.170https://on.cypress.io/not-installed-ci-error171----------172Platform: darwin (Foo-OsVersion)173Cypress Version: 1.2.3...

Full Screen

Full Screen

utils-spec.js

Source:utils-spec.js Github

copy

Full Screen

1/* global describe, context, it */2const { expect } = require('chai')3const { splitToWords, findFuzzyMatches, isFuzzyMatch } = require('./utils')4describe('utils', () => {5 context('isFuzzyMatch', () => {6 it('flags :', () => {7 expect(isFuzzyMatch('t:f')).to.equal(true)8 expect(isFuzzyMatch('t:')).to.equal(true)9 })10 it('flags -', () => {11 expect(isFuzzyMatch('t-f')).to.equal(true)12 expect(isFuzzyMatch('t-')).to.equal(true)13 })14 it('skips =', () => {15 expect(isFuzzyMatch('t=f')).to.equal(false)16 })17 it('uses . at the end', () => {18 expect(isFuzzyMatch('c-r.')).to.equal(true)19 // means we ONLY expect "c" script to match20 expect(isFuzzyMatch('c.')).to.equal(true)21 // this is not a fuzzy match - there are no separators22 // and the dot is NOT at the end23 expect(isFuzzyMatch('c.e')).to.equal(false)24 })25 })26 context('splitToWords', () => {27 it('splits by :', () => {28 const parts = splitToWords('c:r')29 expect(parts).to.deep.equal(['c', 'r'])30 })31 it('splits by : longer words', () => {32 const parts = splitToWords('cy:ru')33 expect(parts).to.deep.equal(['cy', 'ru'])34 })35 it('splits by -', () => {36 const parts = splitToWords('c-r')37 expect(parts).to.deep.equal(['c', 'r'])38 })39 it('removes . at the end', () => {40 const parts = splitToWords('c-r.')41 expect(parts).to.deep.equal(['c', 'r'])42 })43 it('ignores . in the middle', () => {44 const parts = splitToWords('c.r.')45 expect(parts).to.deep.equal(['c.r'])46 })47 })48 context('findFuzzyMatches', () => {49 it('matches single letters', () => {50 const scripts = {51 'cypress:open': 'cypress open',52 'cypress:run': 'cypress run'53 }54 const matched = findFuzzyMatches('c:r', scripts)55 expect(matched).to.deep.equal(['cypress:run'])56 })57 it('returns multiple matches', () => {58 const scripts = {59 'cypress:open': 'cypress open',60 'cypress:run': 'cypress run',61 'cypress:run:record': 'cypress run --record'62 }63 const matched = findFuzzyMatches('c:r', scripts)64 expect(matched).to.deep.equal(['cypress:run', 'cypress:run:record'])65 })66 it('returns multiple matches without single', () => {67 const scripts = {68 cy: 'cypress open',69 cypress: 'cypress open',70 'cypress:open': 'cypress open',71 'cypress:run': 'cypress run',72 'cypress:run:record': 'cypress run --record'73 }74 const matched = findFuzzyMatches('c:', scripts)75 // not that "cy" and "cypress" are single workds76 // so they are not in the returned list77 expect(matched).to.deep.equal([78 'cypress:open', 'cypress:run', 'cypress:run:record'79 ])80 })81 it('returns all matches', () => {82 const scripts = {83 cy: 'cypress open',84 cypress: 'cypress open',85 'cypress:open': 'cypress open',86 'cypress:run': 'cypress run',87 'cypress:run:record': 'cypress run --record'88 }89 const matched = findFuzzyMatches('c', scripts)90 expect(matched).to.deep.equal(Object.keys(scripts))91 })92 it('matches several letters', () => {93 const scripts = {94 'cypress:open': 'cypress open',95 'cypress:run': 'cypress run'96 }97 const matched = findFuzzyMatches('cy:run', scripts)98 expect(matched).to.deep.equal(['cypress:run'])99 })100 it('matches two first parts', () => {101 const scripts = {102 'cypress:open': 'cypress open',103 'cypress:run:there': 'cypress run'104 }105 const matched = findFuzzyMatches('c:r', scripts)106 expect(matched).to.deep.equal(['cypress:run:there'])107 })108 it('matches using -', () => {109 const scripts = {110 'cy:open': 'cypress open',111 'cy:run': 'cypress run'112 }113 const matched = findFuzzyMatches('c-r', scripts)114 expect(matched).to.deep.equal(['cy:run'])115 })116 it('allows scripts to have -', () => {117 const scripts = {118 'cy-open': 'cypress open',119 'cy-run': 'cypress run'120 }121 const matched = findFuzzyMatches('c-r', scripts)122 expect(matched).to.deep.equal(['cy-run'])123 })124 it('finds nothing', () => {125 const scripts = {126 'cypress:open': 'cypress open',127 'cypress:run': 'cypress run'128 }129 // should not crash and return nothing130 const matched = findFuzzyMatches('c:r:r', scripts)131 expect(matched).to.deep.equal([])132 })133 it('finds test-foo by t:f', () => {134 const scripts = {135 test: 'mocha',136 'test-foo': 'mocha ./foo'137 }138 const matched = findFuzzyMatches('t:f', scripts)139 expect(matched).to.deep.equal(['test-foo'])140 })141 describe('stopper', () => {142 it('matches the number of words', () => {143 const scripts = {144 cypress: 'cypress -help',145 'cypress:open': 'cypress open',146 'cypress:run': 'cypress run'147 }148 const matched = findFuzzyMatches('c-r.', scripts)149 expect(matched, 'cypress:run matches c-r.').to.deep.equal(['cypress:run'])150 const matched2 = findFuzzyMatches('cy:op.', scripts)151 expect(matched2, 'cypress:open matches cy:op.').to.deep.equal(['cypress:open'])152 const matched3 = findFuzzyMatches('c.', scripts)153 expect(matched3, 'cypress matches c.').to.deep.equal(['cypress'])154 })155 })156 })...

Full Screen

Full Screen

spec.js

Source:spec.js Github

copy

Full Screen

...42 chdir.to(projectFolder)43 })44 afterEach(chdir.back)45 it('returns with all successful tests', () =>46 cypress.run()47 .then(R.tap(debug))48 .then(normalize)49 .then(pickImportant)50 .then(snapshot)51 )52 it('runs specific spec', () => {53 return cypress.run({54 spec: 'cypress/integration/a-spec.js'55 }).then(R.tap(debug))56 .then((result) => {57 la(result.totalTests === 1, 'there should be single test', result.totalTests)58 })59 })60 it('runs specific spec using absolute path', () => {61 const absoluteSpec = join(projectFolder, 'cypress/integration/a-spec.js')62 debug('absolute path to the spec: %s', absoluteSpec)63 return cypress.run({64 spec: absoluteSpec65 }).then(R.tap(debug))66 .then((result) => {67 la(result.totalTests === 1, 'there should be single test', result.totalTests)68 })69 })70 it('runs a single spec using wildcard', () => {71 return cypress.run({72 spec: 'cypress/integration/a-*.js'73 }).then(R.tap(debug))74 .then((result) => {75 la(result.totalTests === 1, 'there should be single test', result.totalTests)76 })77 })78 it('runs both found specs using wildcard', () => {79 return cypress.run({80 spec: 'cypress/integration/a-*.js,cypress/integration/b-*.js'81 }).then(R.tap(debug))82 .then((result) => {83 la(result.totalTests === 2, 'found both tests', result.totalTests)84 })85 })86})87describe('env variables', () => {88 const projectFolder = fromFolder('env')89 beforeEach(() => {90 chdir.to(projectFolder)91 })92 afterEach(chdir.back)93 it('passes environment variables in the object', () => {94 return cypress.run({95 spec: 'cypress/integration/env-spec.js',96 env: {97 foo: {98 bar: 'baz'99 },100 another: 42101 }102 })103 })104})105describe('failing test', () => {106 beforeEach(() => {107 chdir.to(fromFolder('failing'))108 })109 afterEach(chdir.back)110 it('returns correct number of failing tests', () =>111 cypress.run()112 .then(normalize)113 .then(pickImportant)114 .then(snapshot)115 )116})117// https://github.com/cypress-io/cypress-test-module-api/issues/3118describe('invalid malformed spec file', () => {119 beforeEach(() => {120 chdir.to(fromFolder('invalid'))121 })122 afterEach(chdir.back)123 it('returns with error code', () =>124 // test has reference error on load125 cypress.run({126 spec: './cypress/integration/a-spec.js'127 })128 .then(normalize)129 .then(pickImportant)130 .then(snapshot)131 )...

Full Screen

Full Screen

cypressRun.js

Source:cypressRun.js Github

copy

Full Screen

...4var d = new Date();5// console.log("\ncypressRun NRICFIN: " + person.getNricFin());6// console.log("\ncypressRun Mobile: " + person.getMobileNumber());7var runCheckIn = async function() {8 await cypress.run({9 config: {10 video: false,11 // pluginsFile: './cypress/plugins/index.js',12 screenshotsFolder: './reports',13 trashAssetsBeforeRuns: false14 },15 env: {16 baseUrl: process.env.SAFE_ENTRY_URL,17 nricFin: person.getNricFin(),18 mobileNum: person.getMobileNumber(),19 },20 headless: true,21 quiet: true,22 spec: './cypress/integration/safeentry.checkin.spec.js'23 })24 .then((results) => {25 // console.log("CYPRESS RUN CHECKIN: SUCCESS FOR: " + person.getNricFin() + " on " + d)26 return "SUCCESS"27 })28 .catch((err) => {29 return "FAILED"30 })31}32var runCheckOut = async function() {33 await cypress.run({34 config: {35 // baseUrl: process.env.SAFE_ENTRY_URL,36 video: false,37 // pluginsFile: './cypress/plugins/index.js',38 screenshotsFolder: './reports',39 trashAssetsBeforeRuns: false40 },41 env: {42 baseUrl: process.env.SAFE_ENTRY_URL,43 nricFin: person.getNricFin(),44 mobileNum: person.getMobileNumber(),45 },46 headless: true,47 quiet: true,...

Full Screen

Full Screen

versions.js

Source:versions.js Github

copy

Full Screen

1const Promise = require('bluebird')2const debug = require('debug')('cypress:cli')3const path = require('path')4const util = require('../util')5const state = require('../tasks/state')6const { throwFormErrorText, errors } = require('../errors')7const getVersions = () => {8 return Promise.try(() => {9 if (util.getEnv('CYPRESS_RUN_BINARY')) {10 let envBinaryPath = path.resolve(util.getEnv('CYPRESS_RUN_BINARY'))11 return state.parseRealPlatformBinaryFolderAsync(envBinaryPath)12 .then((envBinaryDir) => {13 if (!envBinaryDir) {14 return throwFormErrorText(errors.CYPRESS_RUN_BINARY.notValid(envBinaryPath))()15 }16 debug('CYPRESS_RUN_BINARY has binaryDir:', envBinaryDir)17 return envBinaryDir18 })19 .catch({ code: 'ENOENT' }, (err) => {20 return throwFormErrorText(errors.CYPRESS_RUN_BINARY.notValid(envBinaryPath))(err.message)21 })22 }23 return state.getBinaryDir()24 })25 .then(state.getBinaryPkgVersionAsync)26 .then((binaryVersion) => {27 return {28 package: util.pkgVersion(),29 binary: binaryVersion || 'not installed',30 }31 })32}33module.exports = {34 getVersions,...

Full Screen

Full Screen

challenge.js

Source:challenge.js Github

copy

Full Screen

1/* 2 🚀 challenge #1: open cypress.json file and try to change 3 "testFiles" option so that you will not need to pass the4 --spec argument when running npx cypress run command5*/ 6/* 7 🚀 challenge #2: go to http://on.cypress.io/cli#cypress-run and8 look into different options you can pass on npx cypress run 9 command. try chaning browser or env variables by passing 10 arguments to the npx cypress run command...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const cypress = require('cypress')2cypress.run({3 reporterOptions: {4 }5})6You can run your tests in Docker by using the [cypress/base:10](

Full Screen

Using AI Code Generation

copy

Full Screen

1const cypress = require('cypress');2const {merge} = require('mochawesome-merge');3const generator = require('mochawesome-report-generator');4cypress.run({5 reporterOptions: {6 }7}).then((results) => {8 merge({9 timestamp: new Date().toISOString()10 });11 generator.create({12 timestamp: new Date().toISOString()13 });14}).catch((err) => {15 console.error(err);16 process.exit(1);17});18"scripts": {19}

Full Screen

Using AI Code Generation

copy

Full Screen

1const cypress = require('cypress');2cypress.run({3 reporterOptions: {4 }5}).then((results) => {6 console.log(results);7}).catch((err) => {8 console.error(err);9});10{11 "reporterOptions": {12 }13}

Full Screen

Using AI Code Generation

copy

Full Screen

1const cypress = require('cypress')2const { merge } = require('mochawesome-merge')3const generator = require('mochawesome-report-generator')4cypress.run({5 reporterOptions: {6 },7 config: {8 }9}).then((results) => {10 merge({11 })12 generator.create({13 })14}).catch((err) => {15 console.error(err)16})

Full Screen

Using AI Code Generation

copy

Full Screen

1const cypress = require('cypress');2cypress.run({3}).then((results) => {4 console.log(results);5})6const { run } = require('cypress');7run({8}).then((results) => {9 console.log(results);10})11const cypress = require('cypress');12cypress.run({13}).then((results) => {14 console.log(results);15})16const { run } = require('cypress');17run({18}).then((results) => {19 console.log(results);20})21const cypress = require('cypress');22cypress.run({23}).then((results) => {24 console.log(results);25})26const { run } = require('cypress');27run({28}).then((results) => {29 console.log(results);30})31const cypress = require('cypress');32cypress.run({33}).then((results) => {34 console.log(results);35})36const { run } = require('cypress');37run({38}).then((results) => {39 console.log(results);40})41const cypress = require('cypress');42cypress.run({43}).then((results) => {44 console.log(results);45})46const { run } = require('cypress');47run({48}).then((results) => {

Full Screen

Using AI Code Generation

copy

Full Screen

1const cypress = require('cypress')2cypress.run({3 reporterOptions: {4 },5})6 .then((results) => {7 console.log(results)8 })9 .catch((err) => {10 console.error(err)11 })12{13 "scripts": {14 },15 "devDependencies": {16 }17}

Full Screen

Using AI Code Generation

copy

Full Screen

1const cypress = require('cypress');2cypress.run({3 reporterOptions: {4 }5}).then((results) => {6 console.log(results)7 process.exit(results.totalFailed)8})

Full Screen

Using AI Code Generation

copy

Full Screen

1const cypress = require('cypress')2const fs = require('fs-extra')3fs.removeSync('cypress/report')4cypress.run({5 reporterOptions: {6 }7})8{9 "scripts": {10 },11 "devDependencies": {12 }13}14{15 "scripts": {16 },17 "devDependencies": {

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