How to use findUp method in Cypress

Best JavaScript code snippet using cypress

options.spec.js

Source:options.spec.js Github

copy

Full Screen

1'use strict';2const {createSandbox} = require('sinon');3const rewiremock = require('rewiremock/node');4const {ONE_AND_DONE_ARGS} = require('../../../lib/cli/one-and-dones');5const modulePath = require.resolve('../../../lib/cli/options');6const mocharcPath = require.resolve('../../../lib/mocharc.json');7const configPath = require.resolve('../../../lib/cli/config');8const proxyLoadOptions = ({9  readFileSync = {},10  findupSync = null,11  findConfig = {},12  loadConfig = {}13} = {}) =>14  rewiremock.proxy(modulePath, r => ({15    fs: r.with({readFileSync}).directChildOnly(),16    [mocharcPath]: defaults,17    'find-up': r18      .by(() => (findupSync ? {sync: findupSync} : {}))19      .directChildOnly(),20    [configPath]: r.with({findConfig, loadConfig}).directChildOnly()21  })).loadOptions;22const defaults = {23  timeout: 1000,24  timeouts: 1000,25  t: 1000,26  extension: ['js']27};28describe('options', function() {29  let sandbox;30  let readFileSync;31  let findupSync;32  let loadOptions;33  let findConfig;34  let loadConfig;35  beforeEach(function() {36    sandbox = createSandbox();37  });38  afterEach(function() {39    sandbox.restore();40  });41  /**42   * Order of priority:43   * 1. Command-line args44   * 2. RC file (`.mocharc.js`, `.mocharc.ya?ml`, `mocharc.json`)45   * 3. `mocha` prop of `package.json`46   * 4. default rc47   */48  describe('loadOptions()', function() {49    describe('when no parameter provided', function() {50      beforeEach(function() {51        this.timeout(1000);52        readFileSync = sandbox.stub();53        readFileSync.onFirstCall().returns('{}');54        findConfig = sandbox.stub().returns('/some/.mocharc.json');55        loadConfig = sandbox.stub().returns({});56        findupSync = sandbox.stub().returns('/some/package.json');57        loadOptions = proxyLoadOptions({58          readFileSync,59          findConfig,60          loadConfig,61          findupSync62        });63      });64      it('should return an object containing positional args, defaults, and anti-reloading flags', function() {65        expect(66          loadOptions(),67          'to equal',68          Object.assign({}, defaults, {69            _: [],70            config: false,71            package: false72          })73        );74      });75    });76    describe('when parameter provided', function() {77      describe('package.json', function() {78        describe('when path to package.json (`--package <path>`) is valid', function() {79          let result;80          beforeEach(function() {81            const filepath = '/some/package.json';82            readFileSync = sandbox.stub();83            // package.json84            readFileSync.onFirstCall().returns('{"mocha": {"retries": 3}}');85            findConfig = sandbox.stub().returns('/some/.mocharc.json');86            loadConfig = sandbox.stub().returns({});87            findupSync = sandbox.stub();88            loadOptions = proxyLoadOptions({89              readFileSync,90              findConfig,91              loadConfig,92              findupSync93            });94            result = loadOptions(['--package', filepath]);95          });96          it('should return merged options incl. package.json opts', function() {97            expect(98              result,99              'to equal',100              Object.assign(101                {102                  _: []103                },104                defaults,105                {106                  config: false,107                  package: false,108                  retries: 3109                }110              )111            );112          });113          it('should not try to find a package.json', function() {114            expect(findupSync, 'was not called');115          });116          it('should set package = false', function() {117            expect(result, 'to have property', 'package', false);118          });119        });120        describe('when path to package.json (`--package <path>`) is invalid', function() {121          beforeEach(function() {122            readFileSync = sandbox.stub();123            // package.json124            readFileSync.onFirstCall().throws('yikes');125            findConfig = sandbox.stub().returns('/some/.mocharc.json');126            loadConfig = sandbox.stub().returns({});127            findupSync = sandbox.stub();128            loadOptions = proxyLoadOptions({129              readFileSync,130              findConfig,131              loadConfig,132              findupSync133            });134          });135          it('should throw', function() {136            expect(137              () => {138                loadOptions('--package /something/wherever --require butts');139              },140              'to throw',141              /unable to read\/parse/i142            );143          });144        });145        describe('when path to package.json unspecified', function() {146          let result;147          beforeEach(function() {148            const filepath = '/some/package.json';149            readFileSync = sandbox.stub();150            // package.json151            readFileSync152              .onFirstCall()153              .returns('{"mocha": {"retries": 3, "_": ["foobar.spec.js"]}}');154            findConfig = sandbox.stub().returns('/some/.mocharc.json');155            loadConfig = sandbox.stub().returns({});156            findupSync = sandbox.stub().returns(filepath);157            loadOptions = proxyLoadOptions({158              readFileSync,159              findConfig,160              loadConfig,161              findupSync162            });163            result = loadOptions();164          });165          it('should return merged options incl. found package.json', function() {166            expect(167              result,168              'to equal',169              Object.assign(170                {171                  _: ['foobar.spec.js']172                },173                defaults,174                {175                  config: false,176                  package: false,177                  retries: 3178                }179              )180            );181          });182          it('should set package = false', function() {183            expect(result, 'to have property', 'package', false);184          });185        });186        describe('when called with package = false (`--no-package`)', function() {187          let result;188          beforeEach(function() {189            readFileSync = sandbox.stub();190            readFileSync.onFirstCall().returns('{}');191            findConfig = sandbox.stub().returns('/some/path/to/.mocharc.json');192            loadConfig = sandbox.stub().returns({'check-leaks': true});193            findupSync = sandbox.stub().returns('/some/package.json');194            loadOptions = proxyLoadOptions({195              readFileSync,196              findConfig,197              loadConfig,198              findupSync199            });200            result = loadOptions('--no-diff --no-package');201          });202          it('should return parsed args and default config', function() {203            expect(204              result,205              'to equal',206              Object.assign({_: []}, defaults, {207                diff: false,208                'check-leaks': true,209                config: false,210                package: false211              })212            );213          });214          it('should not look for package.json', function() {215            expect(findupSync, 'was not called');216          });217          it('should set package = false', function() {218            expect(result, 'to have property', 'package', false);219          });220        });221      });222      describe('rc file', function() {223        describe('when called with config = false (`--no-config`)', function() {224          let result;225          beforeEach(function() {226            readFileSync = sandbox.stub();227            readFileSync228              .onFirstCall()229              .returns(230                '{"mocha": {"check-leaks": true, "_": ["foobar.spec.js"]}}'231              );232            findConfig = sandbox.stub();233            loadConfig = sandbox.stub();234            findupSync = sandbox.stub().returns('/some/package.json');235            loadOptions = proxyLoadOptions({236              readFileSync,237              findConfig,238              loadConfig,239              findupSync240            });241            result = loadOptions('--no-diff --no-config');242          });243          it('should return parsed args, default config and package.json', function() {244            expect(245              result,246              'to equal',247              Object.assign({_: ['foobar.spec.js']}, defaults, {248                diff: false,249                'check-leaks': true,250                config: false,251                package: false252              })253            );254          });255          it('should not attempt to load a config file', function() {256            expect(loadConfig, 'was not called');257          });258          it('should not attempt to find a config file', function() {259            expect(findConfig, 'was not called');260          });261          it('should set config = false', function() {262            expect(loadOptions(), 'to have property', 'config', false);263          });264        });265        describe('when path to config (`--config <path>`) is invalid', function() {266          let config;267          beforeEach(function() {268            readFileSync = sandbox.stub();269            config = '/some/.mocharc.json';270            readFileSync.onFirstCall().returns('{}');271            findConfig = sandbox.stub();272            loadConfig = sandbox.stub().throws('Error', 'failed to parse');273            findupSync = sandbox.stub().returns('/some/package.json');274            loadOptions = proxyLoadOptions({275              readFileSync,276              findConfig,277              loadConfig,278              findupSync279            });280          });281          it('should not look for a config', function() {282            try {283              loadOptions(`--config ${config}`);284            } catch (ignored) {}285            expect(findConfig, 'was not called');286          });287          it('should attempt to load file at path', function() {288            try {289              loadOptions(`--config ${config}`);290            } catch (ignored) {}291            expect(loadConfig, 'to have a call satisfying', [config]);292          });293          it('should throw to warn the user', function() {294            expect(295              () => {296                loadOptions(`--config ${config}`);297              },298              'to throw',299              'failed to parse'300            );301          });302        });303        describe('when called with unspecified config', function() {304          describe('when an rc file would be found', function() {305            let result;306            beforeEach(function() {307              readFileSync = sandbox.stub();308              readFileSync.onFirstCall().returns('{}');309              readFileSync.onSecondCall().throws();310              findConfig = sandbox.stub().returns('/some/.mocharc.json');311              loadConfig = sandbox.stub().returns({});312              findupSync = sandbox.stub().returns('/some/package.json');313              loadOptions = proxyLoadOptions({314                readFileSync,315                findConfig,316                loadConfig,317                findupSync318              });319              result = loadOptions();320            });321            it('should look for a config', function() {322              expect(findConfig, 'was called');323            });324            it('should attempt to load file at found path', function() {325              expect(loadConfig, 'to have a call satisfying', [326                '/some/.mocharc.json'327              ]);328            });329            it('should set config = false', function() {330              expect(result, 'to have property', 'config', false);331            });332          });333          describe('when an rc file would not be found', function() {334            let result;335            beforeEach(function() {336              readFileSync = sandbox.stub();337              readFileSync.onFirstCall().returns('{}');338              readFileSync.onSecondCall().throws();339              findConfig = sandbox.stub().returns(null);340              loadConfig = sandbox.stub().returns({});341              findupSync = sandbox.stub().returns('/some/package.json');342              loadOptions = proxyLoadOptions({343                readFileSync,344                findConfig,345                loadConfig,346                findupSync347              });348              result = loadOptions();349            });350            it('should look for a config', function() {351              expect(findConfig, 'was called');352            });353            it('should not attempt to load a config file', function() {354              expect(loadConfig, 'was not called');355            });356            it('should set config = false', function() {357              expect(result, 'to have property', 'config', false);358            });359          });360        });361      });362    });363    describe('config priority', function() {364      it('should prioritize package.json over defaults', function() {365        readFileSync = sandbox.stub();366        readFileSync367          .onFirstCall()368          .returns(369            '{"mocha": {"timeout": 700, "require": "bar", "extension": "ts"}}'370          );371        findConfig = sandbox.stub().returns('/some/.mocharc.json');372        loadConfig = sandbox.stub().returns({});373        findupSync = sandbox.stub().returns('/some/package.json');374        loadOptions = proxyLoadOptions({375          readFileSync,376          findConfig,377          loadConfig,378          findupSync379        });380        expect(loadOptions(), 'to satisfy', {381          timeout: 700,382          require: ['bar'],383          extension: ['ts']384        });385      });386      it('should prioritize rc file over package.json', function() {387        readFileSync = sandbox.stub();388        readFileSync.onFirstCall().returns('{"mocha": {"timeout": 700}}');389        readFileSync.onSecondCall().returns('--timeout 800');390        findConfig = sandbox.stub().returns('/some/.mocharc.json');391        loadConfig = sandbox.stub().returns({timeout: 600});392        findupSync = sandbox.stub().returns('/some/package.json');393        loadOptions = proxyLoadOptions({394          readFileSync,395          findConfig,396          loadConfig,397          findupSync398        });399        expect(loadOptions(), 'to have property', 'timeout', 600);400      });401      it('should prioritize args over rc file', function() {402        readFileSync = sandbox.stub();403        readFileSync.onFirstCall().returns('{"mocha": {"timeout": 700}}');404        readFileSync.onSecondCall().returns('--timeout 800');405        findConfig = sandbox.stub().returns('/some/.mocharc.json');406        loadConfig = sandbox.stub().returns({timeout: 600});407        findupSync = sandbox.stub().returns('/some/package.json');408        loadOptions = proxyLoadOptions({409          readFileSync,410          findConfig,411          loadConfig,412          findupSync413        });414        expect(415          loadOptions('--timeout 500'),416          'to have property',417          'timeout',418          '500'419        );420      });421    });422    describe('when called with a one-and-done arg', function() {423      beforeEach(function() {424        readFileSync = sandbox.stub();425        findConfig = sandbox.stub();426        loadConfig = sandbox.stub();427        findupSync = sandbox.stub();428        loadOptions = proxyLoadOptions({429          readFileSync,430          findConfig,431          loadConfig,432          findupSync433        });434      });435      ONE_AND_DONE_ARGS.forEach(arg => {436        describe(`"${arg}"`, function() {437          it(`should return basic parsed arguments and flag`, function() {438            expect(loadOptions(`--${arg}`), 'to equal', {_: [], [arg]: true});439          });440        });441      });442    });443    describe('"extension" handling', function() {444      describe('when user supplies "extension" option', function() {445        let result;446        beforeEach(function() {447          readFileSync = sandbox.stub();448          readFileSync.onFirstCall().throws();449          findConfig = sandbox.stub().returns('/some/.mocharc.json');450          loadConfig = sandbox.stub().returns({extension: ['tsx']});451          findupSync = sandbox.stub();452          loadOptions = proxyLoadOptions({453            readFileSync,454            findConfig,455            loadConfig,456            findupSync457          });458          result = loadOptions(['--extension', 'ts']);459        });460        it('should not concatenate the default value', function() {461          expect(result, 'to have property', 'extension', ['ts', 'tsx']);462        });463      });464      describe('when user does not supply "extension" option', function() {465        let result;466        beforeEach(function() {467          readFileSync = sandbox.stub();468          readFileSync.onFirstCall().throws();469          findConfig = sandbox.stub().returns('/some/.mocharc.json');470          loadConfig = sandbox.stub().returns({});471          findupSync = sandbox.stub();472          loadOptions = proxyLoadOptions({473            readFileSync,474            findConfig,475            loadConfig,476            findupSync477          });478          result = loadOptions();479        });480        it('should retain the default', function() {481          expect(result, 'to have property', 'extension', ['js']);482        });483      });484    });485    describe('"spec" handling', function() {486      describe('when user supplies "spec" in config and positional arguments', function() {487        let result;488        beforeEach(function() {489          readFileSync = sandbox.stub();490          readFileSync.onFirstCall().throws();491          findConfig = sandbox.stub().returns('/some/.mocharc.json');492          loadConfig = sandbox493            .stub()494            .returns({spec: '{dirA,dirB}/**/*.spec.js'});495          findupSync = sandbox.stub();496          loadOptions = proxyLoadOptions({497            readFileSync,498            findConfig,499            loadConfig,500            findupSync501          });502          result = loadOptions(['*.test.js']);503        });504        it('should place both - unsplitted - into the positional arguments array', function() {505          expect(result, 'to have property', '_', [506            '*.test.js',507            '{dirA,dirB}/**/*.spec.js'508          ]);509        });510      });511    });512    describe('"ignore" handling', function() {513      let result;514      beforeEach(function() {515        readFileSync = sandbox.stub();516        readFileSync.onFirstCall().throws();517        findConfig = sandbox.stub().returns('/some/.mocharc.json');518        loadConfig = sandbox519          .stub()520          .returns({ignore: '{dirA,dirB}/**/*.spec.js'});521        findupSync = sandbox.stub();522        loadOptions = proxyLoadOptions({523          readFileSync,524          findConfig,525          loadConfig,526          findupSync527        });528        result = loadOptions(['--ignore', '*.test.js']);529      });530      it('should not split option values by comma', function() {531        expect(result, 'to have property', 'ignore', [532          '*.test.js',533          '{dirA,dirB}/**/*.spec.js'534        ]);535      });536    });537  });...

Full Screen

Full Screen

test.js

Source:test.js Github

copy

Full Screen

1'use strict';2var fs = require('fs');3var path = require('path');4var expect = require('expect');5var home = require('homedir-polyfill');6var resolve = require('resolve');7var support = require('./support');8expect.extend(support.expectExtras);9var findup = require('../');10var exists = fs.existsSync;11var normalize = support.normalize;12var chdir = support.chdir;13var npm = support.npm;14var isLinux = process.platform === 'linux';15var cwd, actual;16describe('findup-sync', function() {17  before(function(done) {18    fs.writeFileSync(home() + '/_aaa.txt', '');19    fs.writeFileSync(home() + '/_bbb.txt', '');20    done();21  });22  after(function(done) {23    fs.unlinkSync(home() + '/_aaa.txt');24    fs.unlinkSync(home() + '/_bbb.txt');25    done();26  });27  it('should throw when the first arg is not a string or array:', function(cb) {28    try {29      findup();30      cb(new Error('expected an error'));31    } catch (err) {32      expect(err.message).toEqual('findup-sync expects a string or array as the first argument.');33      cb();34    }35  });36  it('should work when no cwd is given', function(done) {37    var actual = findup('package.json');38    expect(actual).toExist();39    expect(actual).toHaveDirname(path.resolve(__dirname, '..'));40    expect(actual).toHaveBasename('package.json');41    expect(normalize(findup('package.json'))).toEqual('package.json');42    done();43  });44  it('should find files in a child directory', function(done) {45    var expected = path.resolve(__dirname, 'fixtures/a/b/file.txt');46    var restore = chdir(path.resolve(__dirname, 'fixtures/a/b/c/d/e/f/g/h'));47    var actual = findup('a/b/file.txt');48    expect(actual).toExist();49    expect(exists(actual)).toExist();50    expect(actual).toEqual(expected);51    restore();52    done();53  });54  it('should find case sensitive files in a child directory', function(done) {55    var expected = path.resolve(__dirname, 'fixtures/a/b/', (isLinux ? 'Mochafile.txt' : 'mochafile.txt'));56    var restore = chdir(path.resolve(__dirname, 'fixtures/a/b/c/d/e/f/g/h'));57    var actual = findup('a/b/mochafile.txt', { nocase: true });58    expect(actual).toExist();59    expect(exists(actual)).toExist();60    expect(actual).toEqual(expected);61    restore();62    done();63  });64  it('should find files in a child directory relative to a cwd', function(done) {65    var expectedFile = path.resolve(__dirname, 'fixtures/a/b/file.txt');66    var expectedA = path.resolve(__dirname, 'fixtures/a/a.txt');67    var tempDir = chdir(path.resolve(__dirname, 'fixtures'));68    var actualFile = findup('a/b/file.txt', { cwd: 'a/b/c/d' });69    expect(actualFile).toExist();70    expect(exists(actualFile)).toExist();71    expect(actualFile).toEqual(expectedFile);72    var actualA = findup('a.txt', { cwd: 'a/b/c/d/e/f' });73    expect(actualA).toExist();74    expect(exists(actualA)).toExist();75    expect(actualA).toEqual(expectedA);76    tempDir();77    done();78  });79  it('should find case sensitive files in a child directory relative to a cwd', function(done) {80    var expectedFile = path.resolve(__dirname, 'fixtures/a/b', (isLinux ? 'Mochafile.txt' : 'mochafile.txt'));81    var expectedA = path.resolve(__dirname, 'fixtures/a/a.txt');82    var tempDir = chdir(path.resolve(__dirname, 'fixtures'));83    var actualFile = findup('a/b/mochafile.txt', { cwd: 'a/b/c/d', nocase: true });84    expect(actualFile).toExist();85    expect(exists(actualFile)).toExist();86    expect(actualFile).toEqual(expectedFile);87    var actualA = findup('a.txt', { cwd: 'a/b/c/d/e/f' });88    expect(actualA).toExist();89    expect(exists(actualA)).toExist();90    expect(actualA).toEqual(expectedA);91    tempDir();92    done();93  });94  it('should support normal (non-glob) file paths:', function(done) {95    var normPath = normalize(findup('package.json', { cwd: path.dirname(resolve.sync('normalize-path')) }));96    expect(normPath).toEqual('node_modules/normalize-path/package.json');97    var isGlob = normalize(findup('package.json', { cwd: path.dirname(resolve.sync('is-glob')) }));98    expect(isGlob).toEqual('node_modules/is-glob/package.json');99    cwd = path.dirname(resolve.sync('normalize-path'));100    var actual = findup('package.json', { cwd: cwd });101    expect(actual).toHaveDirname(cwd);102    expect(actual).toHaveBasename('package.json');103    actual = findup('c/package.json', { cwd: 'test/fixtures/a/b/c/d/e/f/g' });104    expect(actual).toHaveBasename('package.json');105    expect(actual).toHaveDirname('test/fixtures/a/b/c');106    cwd = path.dirname(resolve.sync('is-glob'));107    actual = findup('package.json', { cwd: cwd });108    expect(actual).toHaveDirname(cwd);109    expect(actual).toHaveBasename('package.json');110    done();111  });112  it('should support normal (non-glob) case sensitive file paths:', function(done) {113    actual = findup('c/mochafile.txt', { cwd: 'test/fixtures/a/b/c/d/e/f/g', nocase: true });114    expect(actual).toHaveBasename(isLinux ? 'Mochafile.txt' : 'mochafile.txt');115    expect(actual).toHaveDirname('test/fixtures/a/b/c');116    done();117  });118  it('should support glob patterns', function(done) {119    expect(normalize(findup('**/c/package.json', { cwd: 'test/fixtures/a/b/c/d/e/f/g' }))).toEqual('test/fixtures/a/b/c/package.json');120    expect(normalize(findup('**/one.txt', { cwd: 'test/fixtures/a/b/c/d/e/f/g' }))).toEqual('test/fixtures/a/b/c/d/one.txt');121    expect(normalize(findup('**/two.txt', { cwd: 'test/fixtures/a/b/c/d/e/f/g' }))).toEqual('test/fixtures/a/b/c/two.txt');122    var pkg = normalize(findup('p*.json', { cwd: npm('micromatch') }));123    expect(pkg).toEqual('node_modules/micromatch/package.json');124    var opts = { cwd: 'test/fixtures/a/b/c/d/e/f/g' };125    actual = findup('**/c/package.json', opts);126    expect(actual).toHaveDirname('test/fixtures/a/b/c');127    expect(actual).toHaveBasename('package.json');128    actual = findup('c/package.json', opts);129    expect(actual).toHaveDirname('test/fixtures/a/b/c');130    expect(actual).toHaveBasename('package.json');131    actual = findup('**/ONE.txt', opts);132    expect(actual).toHaveDirname('test/fixtures/a/b/c');133    expect(actual).toHaveBasename('ONE.txt');134    actual = findup('**/two.txt', opts);135    expect(actual).toHaveDirname('test/fixtures/a/b/c');136    expect(actual).toHaveBasename('two.txt');137    cwd = npm('is-glob');138    actual = findup('p*.json', { cwd: cwd });139    expect(actual).toHaveDirname(cwd);140    expect(actual).toHaveBasename('package.json');141    done();142  });143  it('should support case sensitive glob patterns', function(done) {144    expect(normalize(findup('**/c/mochafile.txt', { cwd: 'test/fixtures/a/b/c/d/e/f/g', nocase: true }))).toEqual('test/fixtures/a/b/c/Mochafile.txt');145    expect(normalize(findup('**/one.txt', { cwd: 'test/fixtures/a/b/c/d/e/f/g', nocase: true }))).toEqual('test/fixtures/a/b/c/d/one.txt');146    expect(normalize(findup('**/two.txt', { cwd: 'test/fixtures/a/b/c/d/e/f/g', nocase: true }))).toEqual('test/fixtures/a/b/c/two.txt');147    expect(normalize(findup('mocha*', { cwd: 'test/fixtures/a/b/c', nocase: true }))).toEqual('test/fixtures/a/b/c/Mochafile.txt');148    var opts = { cwd: 'test/fixtures/a/b/c/d/e/f/g', nocase: true };149    actual = findup('**/c/mochafile.txt', opts);150    expect(actual).toHaveDirname('test/fixtures/a/b/c');151    expect(actual).toHaveBasename('Mochafile.txt');152    actual = findup('c/mochafile.txt', opts);153    expect(actual).toHaveDirname('test/fixtures/a/b/c');154    expect(actual).toHaveBasename(isLinux ? 'Mochafile.txt' : 'mochafile.txt');155    opts.nocase = false;156    actual = findup('**/ONE.txt', opts);157    expect(actual).toHaveDirname('test/fixtures/a/b/c');158    expect(actual).toHaveBasename('ONE.txt');159    actual = findup('**/two.txt', opts);160    expect(actual).toHaveDirname('test/fixtures/a/b/c');161    expect(actual).toHaveBasename('two.txt');162    done();163  });164  it('should support arrays of glob patterns', function(done) {165    expect(normalize(findup(['**/c/package.json'], { cwd: 'test/fixtures/a/b/c/d/e/f/g' }))).toEqual('test/fixtures/a/b/c/package.json');166    expect(normalize(findup(['**/one.txt'], { cwd: 'test/fixtures/a/b/c/d/e/f/g' }))).toEqual('test/fixtures/a/b/c/d/one.txt');167    expect(normalize(findup(['**/two.txt'], { cwd: 'test/fixtures/a/b/c/d/e/f/g' }))).toEqual('test/fixtures/a/b/c/two.txt');168    var opts = { cwd: 'test/fixtures/a/b/c/d/e/f/g' };169    actual = findup(['lslsl', '**/c/package.json'], opts);170    expect(actual).toHaveDirname('test/fixtures/a/b/c');171    expect(actual).toHaveBasename('package.json');172    actual = findup(['lslsl', 'c/package.json'], opts);173    expect(actual).toHaveDirname('test/fixtures/a/b/c');174    expect(actual).toHaveBasename('package.json');175    actual = findup(['lslsl', '**/ONE.txt'], opts);176    expect(actual).toHaveDirname('test/fixtures/a/b/c');177    expect(actual).toHaveBasename('ONE.txt');178    actual = findup(['lslsl', '**/two.txt'], opts);179    expect(actual).toHaveDirname('test/fixtures/a/b/c');180    expect(actual).toHaveBasename('two.txt');181    actual = findup(['lslsl', '**/blah.txt'], opts);182    expect(actual === null).toExist();183    cwd = npm('is-glob');184    actual = findup(['lslsl', 'p*.json'], { cwd: cwd });185    expect(actual).toHaveDirname(cwd);186    expect(actual).toHaveBasename('package.json');187    done();188  });189  it('should support micromatch `matchBase` option:', function(done) {190    var opts = { matchBase: true, cwd: 'test/fixtures/a/b/c/d/e/f/g' };191    expect(normalize(findup('package.json', opts))).toEqual('test/fixtures/a/b/c/d/e/f/g/package.json');192    expect(normalize(findup('one.txt', opts))).toEqual('test/fixtures/a/b/c/d/one.txt');193    expect(normalize(findup('two.txt', opts))).toEqual('test/fixtures/a/b/c/two.txt');194    actual = findup('package.json', opts);195    expect(actual).toHaveBasename('package.json');196    expect(actual).toHaveDirname('test/fixtures/a/b/c/d/e/f/g');197    actual = findup('one.txt', opts);198    expect(actual).toHaveBasename('one.txt');199    expect(actual).toHaveDirname('test/fixtures/a/b/c/d');200    actual = findup('two.txt', opts);201    expect(actual).toHaveBasename('two.txt');202    expect(actual).toHaveDirname('test/fixtures/a/b/c');203    done();204  });205  it('should return `null` when no files are found:', function(done) {206    var dep = normalize(findup('*.foo', { cwd: path.dirname(resolve.sync('micromatch')) }));207    expect(dep).toEqual(null);208    expect(findup('**/b*.json', { cwd: npm('is-glob') })).toEqual(null);209    expect(findup('foo.json', { cwd: 'test/fixtures/a/b/c/d/e/f/g' })).toEqual(null);210    expect(findup('foo.json', { cwd: 'test/fixtures/a/b/c/d/e/f/g', matchBase: true })).toEqual(null);211    done();212  });213  it('should support finding file in immediate parent dir', function(done) {214    cwd = path.resolve(__dirname, 'fixtures/a/b/c');215    var actual = findup('a.md', { cwd: cwd });216    expect(actual).toHaveDirname(path.dirname(cwd));217    expect(actual).toHaveBasename('a.md');218    done();219  });220  it('should support micromatch `nocase` option:', function(done) {221    actual = findup('ONE.*', { cwd: 'test/fixtures/a/b/c/d' });222    expect(actual).toHaveBasename('ONE.txt');223    expect(actual).toHaveDirname('test/fixtures/a/b/c');224    actual = findup('ONE.*', { cwd: 'test/fixtures/a/b/c/d', nocase: true });225    expect(actual).toHaveBasename('one.txt');226    expect(actual).toHaveDirname('test/fixtures/a/b/c/d');227    done();228  });229  it('should find files from absolute paths:', function(done) {230    var actual = findup('package.json', { cwd: __dirname });231    expect(actual).toHaveBasename('package.json');232    expect(actual).toHaveDirname(path.resolve(__dirname, '..'));233    actual = findup('one.txt', { cwd: __dirname + '/fixtures/a' });234    expect(actual).toHaveBasename('one.txt');235    expect(actual).toHaveDirname('test/fixtures/a');236    actual = findup('two.txt', { cwd: __dirname + '/fixtures/a/b/c' });237    expect(actual).toHaveBasename('two.txt');238    expect(actual).toHaveDirname('test/fixtures/a/b/c');239    done();240  });241  it('should find files in user home:', function(done) {242    var actual = findup('*', { cwd: home() });243    expect(actual).isPath();244    expect(exists(actual)).toExist();245    expect(actual).toHaveDirname(home());246    done();247  });248  it('should find files in user home using tilde expansion:', function(done) {249    var actual = findup('*', { cwd: '~' });250    expect(actual).isPath();251    expect(exists(actual)).toExist();252    expect(actual).toHaveDirname(home());253    done();254  });255  it('should match files in cwd before searching up', function(done) {256    var actual = findup(['a.txt', 'a.md'], { cwd: __dirname + '/fixtures/a/b' });257    expect(actual).toHaveBasename('a.md');258    expect(actual).toHaveDirname('test/fixtures/a/b');259    done();260  });...

Full Screen

Full Screen

staged.spec.js

Source:staged.spec.js Github

copy

Full Screen

1'use strict';2const fs = require('fs');3const test = require('supertape');4const stub = require('@cloudcmd/stub');5const mockRequire = require('mock-require');6const {isSupported} = require('./supported-files');7const {reRequire, stopAll} = mockRequire;8test('putout: cli: staged', async (t) => {9    const findUp = stub().returns('');10    11    const {get} = reRequire('./staged');12    await get({findUp});13    14    stopAll();15    16    const type = 'directory';17    18    t.calledWith(findUp, ['.git', {type}], 'should call find-up');19    t.end();20});21test('putout: cli: staged: get: statusMatrix: empty', async (t) => {22    const dir = '/putout';23    const findUp = stub().returns(dir);24    const statusMatrix = stub().returns([25    ]);26    27    mockRequire('isomorphic-git', {28        statusMatrix,29    });30    31    const {get} = reRequire('./staged');32    await get({findUp});33    34    stopAll();35    36    const expected = {37        fs,38        dir,39        filter: isSupported,40    };41    42    t.calledWith(statusMatrix, [expected]);43    t.end();44});45test('putout: cli: staged: get: statusMatrix', async (t) => {46    const dir = '/putout';47    const findUp = stub().returns(dir);48    const statusMatrix = stub().returns([49        [ 'packages/putout/lib/cli/index.js', 1, 2, 2 ],50        [ 'packages/putout/lib/cli/staged.js', 1, 2, 3 ],51    ]);52    53    mockRequire('isomorphic-git', {54        statusMatrix,55    });56    57    const {get} = reRequire('./staged');58    await get({findUp});59    60    stopAll();61    62    const expected = {63        fs,64        dir,65        filter: isSupported,66    };67    68    t.calledWith(statusMatrix, [expected]);69    t.end();70});71test('putout: cli: staged: get: statusMatrix: result', async (t) => {72    const dir = '/putout';73    const findUp = stub().returns(dir);74    const statusMatrix = stub().returns([75        [ 'packages/putout/lib/cli/index.js', 1, 2, 2 ],76    ]);77    78    mockRequire('isomorphic-git', {79        statusMatrix,80    });81    82    const {get} = reRequire('./staged');83    const names = await get({findUp});84    85    stopAll();86    87    const expected = [88        '/putout/packages/putout/lib/cli/index.js',89    ];90    91    t.deepEqual(names, expected);92    t.end();93});94test('putout: cli: staged: set: findUp', async (t) => {95    const dir = '/putout';96    const findUp = stub().returns(dir);97    const statusMatrix = stub().returns([98        [ 'packages/putout/lib/cli/index.js', 1, 2, 2 ],99    ]);100    101    mockRequire('isomorphic-git', {102        statusMatrix,103    });104    105    const {set} = reRequire('./staged');106    await set({findUp});107    108    stopAll();109    110    const type = 'directory';111    112    t.calledWith(findUp, ['.git', {type}]);113    t.end();114});115test('putout: cli: staged: set: findUp: not found', async (t) => {116    const dir = '';117    const findUp = stub().returns(dir);118    const statusMatrix = stub().returns([119        [ 'packages/putout/lib/cli/index.js', 1, 2, 2 ],120    ]);121    122    mockRequire('isomorphic-git', {123        statusMatrix,124    });125    126    const {set} = reRequire('./staged');127    await set({findUp});128    129    stopAll();130    131    const type = 'directory';132    133    t.calledWith(findUp, ['.git', {type}]);134    t.end();135});136test('putout: cli: staged: add', async (t) => {137    const dir = '/putout';138    const findUp = stub().returns(dir);139    const statusMatrix = stub().returns([140        [ 'packages/putout/lib/cli/index.js', 1, 2, 2 ],141    ]);142    143    const add = stub();144    const status = stub().returns('modified');145    146    mockRequire('fs', {});147    mockRequire('isomorphic-git', {148        add,149        status,150        statusMatrix,151    });152    153    const {get, set} = reRequire('./staged');154    155    await get({findUp});156    await set({findUp});157    158    stopAll();159    160    const filepath = 'packages/putout/lib/cli/index.js';161    const fs = {};162    163    t.calledWith(add, [{fs, dir, filepath}]);164    t.end();...

Full Screen

Full Screen

findup-test.js

Source:findup-test.js Github

copy

Full Screen

1var assert = require('chai').assert,2  Path = require('path'),3  fs = require('fs'),4  findup = require('..');5describe('find-up', function(){6  var fixtureDir = Path.join(__dirname, 'fixture', 'f', 'e', 'd', 'c', 'b', 'a'),7    fsExists = fs.exists ? fs.exists : Path.exists;8  it('accept a function', function(done){9    findup(fixtureDir, function(dir, cb){10      return fsExists(Path.join(dir, 'config.json'), cb);11    }, function(err, file){12      assert.ifError(err);13      assert.equal(file, Path.join(__dirname, 'fixture', 'f', 'e', 'd', 'c'));14      done();15    });16  });17  it('accept a string', function(done){18    findup(fixtureDir, 'config.json', function(err, file){19      assert.ifError(err);20      assert.equal(file, Path.join(__dirname, 'fixture', 'f', 'e', 'd', 'c'));21      done();22    });23  });24  it('is usable with the Object syntax', function(done) {25    new findup.FindUp(fixtureDir, 'config.json', function(err, file){26      assert.ifError(err);27      assert.equal(file, Path.join(__dirname, 'fixture', 'f', 'e', 'd', 'c'));28      done();29    });30  });31  it('find several files when using with the EventEmitter syntax', function(done){32    var ee = new findup.FindUp(fixtureDir, 'config.json');33    ee.once('found', function(file){34      assert.equal(file, Path.join(__dirname, 'fixture', 'f', 'e', 'd', 'c'));35      ee.once('found', function(file){36        assert.equal(file, Path.join(__dirname, 'fixture'));37        ee.once('end', function(){38          done();39        });40      });41    });42  });43  it('return files in top dir', function(done){44    findup(fixtureDir, 'top.json', function(err, file){45      assert.ifError(err);46      assert.equal(file, Path.join(__dirname, 'fixture', 'f', 'e', 'd', 'c', 'b', 'a'));47      done();48    });49  });50  it('return files in root dir', function(done){51    findup(fixtureDir, 'dev', function(err, file){52      assert.ifError(err);53      assert.equal(file, '/');54      done();55    });56  });57  it('return an error when looking for non existiong files', function(done){58    findup(fixtureDir, 'toto.json', function(err, file){59      assert.isNotNull(err);60      done();61    });62  });63  it('return an error when looking in a non existing directory', function(done){64    findup('dsqkjfnqsdkjghq', 'toto.json', function(err, file){65      assert.isNotNull(err);66      done();67    });68  });69  it('trigger an error event when looking in a non existing directory', function(done){70    findup('dsqkjfnqsdkjghq', 'toto.json').on('error', function(err, files){71      assert.isNotNull(err);72      done();73    });74  });75  describe('Sync API', function(){76    it('accept a string', function(){77      var file = findup.sync(fixtureDir, 'config.json');78      assert.equal(file, Path.join(__dirname, 'fixture', 'f', 'e', 'd', 'c'));79    });80    it('return a file in top dir', function(){81      var file = findup.sync(fixtureDir, 'top.json');82      assert.equal(file, Path.join(__dirname, 'fixture', 'f', 'e', 'd', 'c', 'b', 'a'));83    });84    it('throw error when looking for a non existing file', function(){85      assert.throw(function(){86        findup.sync(fixtureDir, 'toto.json');87      });88    });89    it('throw error when looking for in a non existing directory', function(){90      assert.throw(function(){91        findup.sync('uhjhbjkg,nfg', 'toto.json');92      });93    });94  });...

Full Screen

Full Screen

findup-sync_test.js

Source:findup-sync_test.js Github

copy

Full Screen

1'use strict';2// Nodejs lib.3var path = require('path');4var findup = require('../lib/findup-sync.js');5// Get a relative path.6var rel = function(abspath) {7  return typeof abspath === 'string' ? path.relative('.', abspath) : abspath;8};9exports['findup'] = {10  setUp: function(done) {11    this.cwd = process.cwd();12    done();13  },14  tearDown: function(done) {15    process.chdir(this.cwd);16    done();17  },18  'simple': function(test) {19    test.expect(8);20    var opts = {cwd: 'test/fixtures/a/b'};21    test.equal(rel(findup('foo.txt', opts)), path.normalize('test/fixtures/a/foo.txt'), 'should find files');22    test.equal(rel(findup('bar.txt', opts)), path.normalize('test/fixtures/a/b/bar.txt'), 'should find files');23    test.equal(rel(findup('a.txt', opts)), path.normalize('test/fixtures/a.txt'), 'should find files');24    test.equal(rel(findup('?.txt', opts)), path.normalize('test/fixtures/a.txt'), 'should support glob patterns');25    test.equal(rel(findup('*.txt', opts)), path.normalize('test/fixtures/a/b/bar.txt'), 'should find the first thing that matches the glob pattern');26    test.equal(rel(findup(['b*.txt', 'f*.txt'], opts)), path.normalize('test/fixtures/a/b/bar.txt'), 'should find the first thing that matches any of the glob patterns');27    test.equal(rel(findup(['f*.txt', 'b*.txt'], opts)), path.normalize('test/fixtures/a/b/bar.txt'), 'should find the first thing that matches any of the glob patterns');28    test.equal(findup('not-gonna-exist-i-hope.txt', opts), null, 'should returning null if no files found');29    test.done();30  },31  'cwd': function(test) {32    test.expect(8);33    process.chdir('test/fixtures/a/b');34    test.equal(rel(findup('foo.txt')), path.normalize('../foo.txt'), 'should find files');35    test.equal(rel(findup('bar.txt')), 'bar.txt', 'should find files');36    test.equal(rel(findup('a.txt')), path.normalize('../../a.txt'), 'should find files');37    test.equal(rel(findup('?.txt')), path.normalize('../../a.txt'), 'should support glob patterns');38    test.equal(rel(findup('*.txt')), 'bar.txt', 'should find the first thing that matches the glob pattern');39    test.equal(rel(findup(['b*.txt', 'f*.txt'])), 'bar.txt', 'should find the first thing that matches any of the glob patterns');40    test.equal(rel(findup(['f*.txt', 'b*.txt'])), 'bar.txt', 'should find the first thing that matches any of the glob patterns');41    test.equal(findup('not-gonna-exist-i-hope.txt'), null, 'should returning null if no files found');42    test.done();43  },...

Full Screen

Full Screen

findup.test.js

Source:findup.test.js Github

copy

Full Screen

1'use strict';2var assert = require('assert');3var path = require('path');4var findup = require('../../lib/findup');5describe('lib: findup', function() {6  var fixturesDir = path.resolve(__dirname, '../fixtures/findup');7  var expected = path.resolve(fixturesDir, 'd1/package.json');8  it('findup a file in the current directory', function() {9    var dir = path.join(fixturesDir, 'd1');10    assert.equal(findup('package.json', dir), expected);11  });12  it('findup a file in the child directory', function() {13    var dir = path.join(fixturesDir, 'd1/d2');14    assert.equal(findup('package.json', dir), expected);15  });16  it('findup a file in the descendant directory', function() {17    var dir = path.join(fixturesDir, 'd1/d2/d3');18    assert.equal(findup('package.json', dir), expected);19  });20  it('findup inexistent file', function() {21    var dir = path.join(fixturesDir, 'd1/d2/d3');22    assert.equal(findup('xxx', dir), null);23  });24  it('findup inexistent dir', function() {25    var dir = path.join(fixturesDir, 'd1/d2/xx');26    assert.equal(findup('xxx', dir), null);27  });28  it('specified path is a directory', function() {29    var dir = path.join(fixturesDir, 'd1');30    assert.equal(findup('d2', dir), null);31  });...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1// Code generated by coz. DO NOT EDIT.2/* eslint-disable */3/**4 * @description Utility for file path5 * @license MIT6 * @module @the-/util-path7 * @typicalname utilPath8 * @version 15.4.129 */10'use strict'11const findup_ = require('./findup')12const findupDir_ = require('./findupDir')13const helpers_ = require('./helpers')14// `module.exports` overrides these `exports.*`, but still needs them for lebab (https://github.com/lebab/lebab)15exports.findup = findup_16exports.findupDir = findupDir_17exports.helpers = helpers_18module.exports = {19  findup: findup_,20  findupDir: findupDir_,21  helpers: helpers_,...

Full Screen

Full Screen

find-up.js

Source:find-up.js Github

copy

Full Screen

1const findUp = require("../dist/compiled/common-packages.js").findUp();2// find-up 6.* changed its exports3// This makes it compatible with both find-up 5.* and 6.*4const findUpExport = findUp.findUp;5findUpExport.sync = findUp.findUpSync;6findUpExport.findUpSync = findUp.findUpSync;7findUpExport.stop = findUp.findUpStop;8findUpExport.findUpStop = findUp.findUpStop;9findUpExport.exists = findUp.pathExists;10findUpExport.pathExists = findUp.pathExists;11findUpExport.sync.exists = findUp.pathExistsSync;12findUpExport.pathExistsSync = findUp.pathExistsSync;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const findUp = require('find-up');2const path = require('path');3const cypressConfigPath = findUp.sync('cypress.json');4const cypressConfig = require(cypressConfigPath);5const cypressConfigFolder = path.dirname(cypressConfigPath);6const cypressConfigParentFolder = path.dirname(cypressConfigFolder);7const cypressConfigParentParentFolder = path.dirname(cypressConfigParentFolder);8const findUp = require('find-up');9const path = require('path');10const cypressConfigPath = findUp.sync('cypress.json');11const cypressConfig = require(cypressConfigPath);12const cypressConfigFolder = path.dirname(cypressConfigPath);13const cypressConfigParentFolder = path.dirname(cypressConfigFolder);14const cypressConfigParentParentFolder = path.dirname(cypressConfigParentFolder);15const findUp = require('find-up');16const path = require('path');17const cypressConfigPath = findUp.sync('cypress.json');18const cypressConfig = require(cypressConfigPath);19const cypressConfigFolder = path.dirname(cypressConfigPath);20const cypressConfigParentFolder = path.dirname(cypressConfigFolder);21const cypressConfigParentParentFolder = path.dirname(cypressConfigParentFolder);22const findUp = require('find-up');23const path = require('path');24const cypressConfigPath = findUp.sync('cypress.json');25const cypressConfig = require(cypressConfigPath);26const cypressConfigFolder = path.dirname(cypressConfigPath);27const cypressConfigParentFolder = path.dirname(cypressConfigFolder);28const cypressConfigParentParentFolder = path.dirname(cypressConfigParentFolder);29const findUp = require('find-up');30const path = require('path');31const cypressConfigPath = findUp.sync('cypress.json');32const cypressConfig = require(cypressConfigPath);33const cypressConfigFolder = path.dirname(cypressConfigPath);34const cypressConfigParentFolder = path.dirname(cypressConfigFolder);35const cypressConfigParentParentFolder = path.dirname(cypressConfigParentFolder);36const findUp = require('find-up');37const path = require('path');

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Find Up', () => {2  it('Find Up', () => {3    cy.get('input[name="q"]').type('Cypress')4    cy.get('input[name="btnK"]').click()5  })6})7Cypress.Commands.add('findUp', { prevSubject: true }, (subject, selector) => {8  if (subject.is(selector)) {9  }10  const parent = subject.parent()11  if (parent.length) {12      .wrap(parent, { log: false })13      .findUp(selector)14  }15  return cy.$$([])16})17declare namespace Cypress {18  interface Chainable {19     * @example cy.get('div').findUp('div')20    findUp(selector: string): Chainable<Element>21  }22}23{24  "testFiles": "**/*.{js,ts}",25}26{27  "scripts": {28  },29  "devDependencies": {

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Cypress findUp', () => {2  it('findUp', () => {3    cy.get('nav').findUp('nav')4  })5})6Cypress.Commands.add('findUp', { prevSubject: true }, (subject, selector) => {7  return cy.wrap(subject).parents(selector).first()8})9describe('Cypress findUp', () => {10  it('findUp', () => {11    cy.get('nav').findUp('nav')12  })13})14describe('Cypress findUp', () => {15  it('findUp', () => {16    cy.get('nav').findUp('nav')17  })18})19describe('Cypress findUp', () => {20  it('findUp', () => {21    cy.get('nav').findUp('nav')22  })23})24describe('Cypress findUp', () => {25  it('findUp', () => {26    cy.get('nav').findUp('nav')27  })28})29describe('Cypress findUp', () => {30  it('findUp', () => {31    cy.get('nav').findUp('nav')32  })33})34describe('Cypress findUp', () => {35  it('findUp', () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2  it('Does not do much!', function() {3    cy.contains('type').click()4    cy.url().should('include', '/commands/actions')5    cy.get('.action-email')6      .findUp('form')7      .should('have.class', 'form-horizontal')8  })9})10Cypress.Commands.add('findUp', { prevSubject: 'element' }, (subject, selector) => {11  return subject.parents().filter(selector).first()12})13import './commands'14describe('My First Test', function() {15  it('Does not do much!', function() {16    cy.contains('type').click()17    cy.url().should('include', '/commands/actions')18    cy.get('.action-email')19      .findUp('form')20      .should('have.class', 'form-horizontal')21  })22})23describe('My First Test', function() {24  it('Does not do much!', function() {25    cy.contains('type').click()26    cy.url().should('include', '/commands/actions')27    cy.get('.action-email')28      .findUp('form')29      .should('have.class', 'form-horizontal')30  })31})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe("findUp method", () => {2  it("finds the first element", () => {3    cy.get("ul").findUp("ul").should("have.id", "querying-root");4  });5});6Cypress.Commands.add("findUp", { prevSubject: true }, (subject, selector) => {7  return cy.wrap(subject).parents().filter(selector).first();8});9{10}11module.exports = (on, config) => {12  on("file:preprocessor", require("@cypress/code-coverage/use-babelrc"));13  return config;14};15describe("findUp method", () => {16  it("finds the first element", () => {17    cy.get("ul").findUp("ul").should("have.id", "querying-root");18  });19});20Cypress.Commands.add("findUp", { prevSubject: true }, (subject, selector) => {21  return cy.wrap(subject).parents().filter(selector).first();22});23{24}25module.exports = (on, config) => {26  on("file:preprocessor", require("@cypress/code-coverage/use-babelrc"));27  return config;28};29describe("findUp method", () => {30  it("finds the first element", () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Find Up', () => {2  it('Find Up', () => {3    cy.get('a').findUp('div').should('contain', 'Docs')4  })5})6Cypress.Commands.add('findUp', { prevSubject: 'element' }, (subject, selector) => {7  return cy.wrap(subject).parentsUntil('body').filter(selector).last()8})9import './commands'10module.exports = (on, config) => {11  require('@cypress/code-coverage/task')(on, config)12}13{14  "env": {15  },16  "reporterOptions": {17    "mochawesomeReporterOptions": {18    },19    "mochawesomeMergeOptions": {20    }21  }22}23{24  "stats": {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { findUp } = require('cypress/lib/util/fs')2const path = require('path')3const fs = require('fs')4const { getTestFiles } = require('cypress/lib/plugins/util')5const { getSpecs } = require('cypress/lib/plugins/node')6const { getSpecsFromFiles } = require('cypress/lib/plugins/node')7const { getSpecsFromFolders } = require('cypress/lib/plugins/node')8const { getSpecsFromGlobs } = require('cypress/lib/plugins/node')9const { getSpecsFromFolders } = require('cypress/lib/plugins/node')10const { getSpecsFromGlobs } = require('cypress/lib/plugins/node')11const { getSpecsFromFiles } = require('cypress/lib/plugins/node')12const { getSpecs } = require('cypress/lib/plugins/node')13const { getSpecsFromFiles } = require('cypress/lib/plugins/node')14const { getSpecsFromFolders } = require('cypress/lib/plugins/node')15const { getSpecsFromGlobs } = require('cypress/lib/plugins/node')16const { getSpecs } = require('cypress/lib/plugins/node')17const { getSpecsFromFiles } = require('cypress/lib/plugins/node')18const { getSpecsFromFolders } = require('cypress/lib/plugins/node')19const { getSpecsFromGlobs } = require('cypress/lib/plugins/node')20const { getSpecs } = require('cypress/lib/plugins/node')21const { getSpecsFromFiles } = require('cypress/lib/plugins/node')22const { getSpecsFromFolders } = require('cypress/lib/plugins/node')23const { getSpecsFromGlobs } = require('cypress/lib/plugins/node')24const { getSpecs } = require('cypress/lib/plugins/node')25const { getSpecsFromFiles } = require('cypress/lib/plugins/node')26const { getSpecsFromFolders } = require('cypress/lib/plugins/node')27const { getSpecsFromGlobs } = require('cypress/lib/plugins/node')28const { getSpecs } = require('cypress/lib/plugins/node')29const { getSpecsFromFiles } = require('cypress/lib/plugins

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