Best JavaScript code snippet using cypress
config_spec.js
Source:config_spec.js
...1531 })1532 })1533 it('sets the full path to the supportFile and supportFolder if it exists', () => {1534 const projectRoot = process.cwd()1535 const obj = config.setAbsolutePaths({1536 projectRoot,1537 supportFile: 'test/unit/config_spec.js',1538 })1539 return config.setSupportFileAndFolder(obj)1540 .then((result) => {1541 expect(result).to.eql({1542 projectRoot,1543 supportFile: `${projectRoot}/test/unit/config_spec.js`,1544 supportFolder: `${projectRoot}/test/unit`,1545 })1546 })1547 })1548 it('sets the supportFile to default index.js if it does not exist, support folder does not exist, and supportFile is the default', () => {1549 const projectRoot = path.join(process.cwd(), 'test/support/fixtures/projects/no-scaffolding')1550 const obj = config.setAbsolutePaths({1551 projectRoot,1552 supportFile: 'cypress/support',1553 })1554 return config.setSupportFileAndFolder(obj)1555 .then((result) => {1556 expect(result).to.eql({1557 projectRoot,1558 supportFile: `${projectRoot}/cypress/support/index.js`,1559 supportFolder: `${projectRoot}/cypress/support`,1560 })1561 })1562 })1563 it('sets the supportFile to false if it does not exist, support folder exists, and supportFile is the default', () => {1564 const projectRoot = path.join(process.cwd(), 'test/support/fixtures/projects/empty-folders')1565 const obj = config.setAbsolutePaths({1566 projectRoot,1567 supportFile: 'cypress/support',1568 })1569 return config.setSupportFileAndFolder(obj)1570 .then((result) => {1571 expect(result).to.eql({1572 projectRoot,1573 supportFile: false,1574 })1575 })1576 })1577 it('throws error if supportFile is not default and does not exist', () => {1578 const projectRoot = process.cwd()1579 const obj = config.setAbsolutePaths({1580 projectRoot,1581 supportFile: 'does/not/exist',1582 })1583 return config.setSupportFileAndFolder(obj)1584 .catch((err) => {1585 expect(err.message).to.include('The support file is missing or invalid.')1586 })1587 })1588 it('sets the supportFile to index.ts if it exists (without ts require hook)', () => {1589 const projectRoot = path.join(process.cwd(), 'test/support/fixtures/projects/ts-proj')1590 const supportFolder = `${projectRoot}/cypress/support`1591 const supportFilename = `${supportFolder}/index.ts`1592 const e = new Error('Cannot resolve TS file by default')1593 e.code = 'MODULE_NOT_FOUND'1594 sinon.stub(config.utils, 'resolveModule').withArgs(supportFolder).throws(e)1595 const obj = config.setAbsolutePaths({1596 projectRoot,1597 supportFile: 'cypress/support',1598 })1599 return config.setSupportFileAndFolder(obj)1600 .then((result) => {1601 debug('result is', result)1602 expect(result).to.eql({1603 projectRoot,1604 supportFolder,1605 supportFile: supportFilename,1606 })1607 })1608 })1609 it('uses custom TS supportFile if it exists (without ts require hook)', () => {1610 const projectRoot = path.join(process.cwd(), 'test/support/fixtures/projects/ts-proj-custom-names')1611 const supportFolder = `${projectRoot}/cypress`1612 const supportFilename = `${supportFolder}/support.ts`1613 const e = new Error('Cannot resolve TS file by default')1614 e.code = 'MODULE_NOT_FOUND'1615 sinon.stub(config.utils, 'resolveModule').withArgs(supportFilename).throws(e)1616 const obj = config.setAbsolutePaths({1617 projectRoot,1618 supportFile: 'cypress/support.ts',1619 })1620 return config.setSupportFileAndFolder(obj)1621 .then((result) => {1622 debug('result is', result)1623 expect(result).to.eql({1624 projectRoot,1625 supportFolder,1626 supportFile: supportFilename,1627 })1628 })1629 })1630 })1631 context('.setPluginsFile', () => {1632 it('does nothing if pluginsFile is falsey', () => {1633 const obj = {1634 projectRoot: '/_test-output/path/to/project',1635 }1636 return config.setPluginsFile(obj)1637 .then((result) => {1638 expect(result).to.eql(obj)1639 })1640 })1641 it('sets the pluginsFile to default index.js if does not exist', () => {1642 const projectRoot = path.join(process.cwd(), 'test/support/fixtures/projects/no-scaffolding')1643 const obj = {1644 projectRoot,1645 pluginsFile: `${projectRoot}/cypress/plugins`,1646 }1647 return config.setPluginsFile(obj)1648 .then((result) => {1649 expect(result).to.eql({1650 projectRoot,1651 pluginsFile: `${projectRoot}/cypress/plugins/index.js`,1652 })1653 })1654 })1655 it('sets the pluginsFile to index.ts if it exists', () => {1656 const projectRoot = path.join(process.cwd(), 'test/support/fixtures/projects/ts-proj-with-module-esnext')1657 const obj = {1658 projectRoot,1659 pluginsFile: `${projectRoot}/cypress/plugins`,1660 }1661 return config.setPluginsFile(obj)1662 .then((result) => {1663 expect(result).to.eql({1664 projectRoot,1665 pluginsFile: `${projectRoot}/cypress/plugins/index.ts`,1666 })1667 })1668 })1669 it('sets the pluginsFile to index.ts if it exists (without ts require hook)', () => {1670 const projectRoot = path.join(process.cwd(), 'test/support/fixtures/projects/ts-proj-with-module-esnext')1671 const pluginsFolder = `${projectRoot}/cypress/plugins`1672 const pluginsFilename = `${pluginsFolder}/index.ts`1673 const e = new Error('Cannot resolve TS file by default')1674 e.code = 'MODULE_NOT_FOUND'1675 sinon.stub(config.utils, 'resolveModule').withArgs(pluginsFolder).throws(e)1676 const obj = {1677 projectRoot,1678 pluginsFile: pluginsFolder,1679 }1680 return config.setPluginsFile(obj)1681 .then((result) => {1682 expect(result).to.eql({1683 projectRoot,1684 pluginsFile: pluginsFilename,1685 })1686 })1687 })1688 it('set the pluginsFile to false if it does not exist, plugins folder exists, and pluginsFile is the default', () => {1689 const projectRoot = path.join(process.cwd(), 'test/support/fixtures/projects/empty-folders')1690 const obj = config.setAbsolutePaths({1691 projectRoot,1692 pluginsFile: `${projectRoot}/cypress/plugins`,1693 })1694 return config.setPluginsFile(obj)1695 .then((result) => {1696 expect(result).to.eql({1697 projectRoot,1698 pluginsFile: false,1699 })1700 })1701 })1702 it('throws error if pluginsFile is not default and does not exist', () => {1703 const projectRoot = process.cwd()1704 const obj = {1705 projectRoot,1706 pluginsFile: 'does/not/exist',1707 }1708 return config.setPluginsFile(obj)1709 .catch((err) => {1710 expect(err.message).to.include('The plugins file is missing or invalid.')1711 })1712 })1713 it('uses custom TS pluginsFile if it exists (without ts require hook)', () => {1714 const projectRoot = path.join(process.cwd(), 'test/support/fixtures/projects/ts-proj-custom-names')1715 const pluginsFolder = `${projectRoot}/cypress`1716 const pluginsFile = `${pluginsFolder}/plugins.ts`1717 const e = new Error('Cannot resolve TS file by default')1718 e.code = 'MODULE_NOT_FOUND'1719 sinon.stub(config.utils, 'resolveModule').withArgs(pluginsFile).throws(e)1720 const obj = {1721 projectRoot,1722 pluginsFile,1723 }1724 return config.setPluginsFile(obj)1725 .then((result) => {1726 expect(result).to.eql({1727 projectRoot,1728 pluginsFile,1729 })1730 })1731 })1732 })1733 context('.setParentTestsPaths', () => {1734 it('sets parentTestsFolder and parentTestsFolderDisplay', () => {1735 const obj = {1736 projectRoot: '/_test-output/path/to/project',1737 integrationFolder: '/_test-output/path/to/project/cypress/integration',1738 }1739 expect(config.setParentTestsPaths(obj)).to.deep.eq({1740 projectRoot: '/_test-output/path/to/project',1741 integrationFolder: '/_test-output/path/to/project/cypress/integration',1742 parentTestsFolder: '/_test-output/path/to/project/cypress',1743 parentTestsFolderDisplay: 'project/cypress',1744 })1745 })1746 it('sets parentTestsFolderDisplay to parentTestsFolder if they are the same', () => {1747 const obj = {1748 projectRoot: '/_test-output/path/to/project',1749 integrationFolder: '/_test-output/path/to/project/tests',1750 }1751 expect(config.setParentTestsPaths(obj)).to.deep.eq({1752 projectRoot: '/_test-output/path/to/project',1753 integrationFolder: '/_test-output/path/to/project/tests',1754 parentTestsFolder: '/_test-output/path/to/project',1755 parentTestsFolderDisplay: 'project',1756 })1757 })1758 })1759 context('.setAbsolutePaths', () => {1760 it('is noop without projectRoot', () => {1761 expect(config.setAbsolutePaths({})).to.deep.eq({})1762 })1763 // it "resolves fileServerFolder with projectRoot", ->1764 // obj = {1765 // projectRoot: "/_test-output/path/to/project"1766 // fileServerFolder: "foo"1767 // }1768 // expect(config.setAbsolutePaths(obj)).to.deep.eq({1769 // projectRoot: "/_test-output/path/to/project"1770 // fileServerFolder: "/_test-output/path/to/project/foo"1771 // })1772 it('does not mutate existing obj', () => {1773 const obj = {}1774 expect(config.setAbsolutePaths(obj)).not.to.eq(obj)1775 })1776 it('ignores non special *folder properties', () => {1777 const obj = {1778 projectRoot: '/_test-output/path/to/project',1779 blehFolder: 'some/rando/path',1780 foo: 'bar',1781 baz: 'quux',1782 }1783 expect(config.setAbsolutePaths(obj)).to.deep.eq(obj)1784 })1785 return ['fileServerFolder', 'fixturesFolder', 'integrationFolder', 'unitFolder', 'supportFile', 'pluginsFile'].forEach((folder) => {1786 it(`converts relative ${folder} to absolute path`, () => {1787 const obj = {1788 projectRoot: '/_test-output/path/to/project',1789 }1790 obj[folder] = 'foo/bar'1791 const expected = {1792 projectRoot: '/_test-output/path/to/project',1793 }1794 expected[folder] = '/_test-output/path/to/project/foo/bar'1795 expect(config.setAbsolutePaths(obj)).to.deep.eq(expected)1796 })1797 })1798 })1799 context('.setNodeBinary', () => {1800 beforeEach(function () {1801 this.findSystemNode = sinon.stub(findSystemNode, 'findNodePathAndVersion')1802 this.nodeVersion = process.versions.node1803 })1804 it('sets current Node ver if nodeVersion != system', function () {1805 return config.setNodeBinary({1806 nodeVersion: undefined,1807 })1808 .then((obj) => {1809 expect(this.findSystemNode).to.not.be.called...
config.js
Source:config.js
...171 config = setResolvedConfigValues(config, defaultsForRuntime, resolved);172 if (config.port) {173 config = setUrls(config);174 }175 config = setAbsolutePaths(config);176 config = setParentTestsPaths(config);177 config = (0, exports.setNodeBinary)(config, (_a = options.args) === null || _a === void 0 ? void 0 : _a.userNodePath, (_b = options.args) === null || _b === void 0 ? void 0 : _b.userNodeVersion);178 // validate config again here so that we catch configuration errors coming179 // from the CLI overrides or env var overrides180 config_1.default.validate(lodash_1.default.omit(config, 'browsers'), (errMsg) => {181 return errors_1.default.throw('CONFIG_VALIDATION_ERROR', errMsg);182 });183 config_1.default.validateNoBreakingConfig(config, errors_1.default.warning, errors_1.default.throw);184 return setSupportFileAndFolder(config, defaultsForRuntime)185 .then((obj) => (0, exports.setPluginsFile)(obj, defaultsForRuntime))186 .then(setScaffoldPaths);187}188exports.mergeDefaults = mergeDefaults;189function setResolvedConfigValues(config, defaults, resolved) {190 const obj = lodash_1.default.clone(config);191 obj.resolved = resolveConfigValues(config, defaults, resolved);192 debug('resolved config is %o', obj.resolved.browsers);193 return obj;194}195exports.setResolvedConfigValues = setResolvedConfigValues;196// Given an object "resolvedObj" and a list of overrides in "obj"197// marks all properties from "obj" inside "resolvedObj" using198// {value: obj.val, from: "plugin"}199function setPluginResolvedOn(resolvedObj, obj) {200 return lodash_1.default.each(obj, (val, key) => {201 if (lodash_1.default.isObject(val) && !lodash_1.default.isArray(val) && resolvedObj[key]) {202 // recurse setting overrides203 // inside of objected204 return setPluginResolvedOn(resolvedObj[key], val);205 }206 const valueFrom = {207 value: val,208 from: 'plugin',209 };210 resolvedObj[key] = valueFrom;211 });212}213exports.setPluginResolvedOn = setPluginResolvedOn;214function updateWithPluginValues(cfg, overrides) {215 if (!overrides) {216 overrides = {};217 }218 debug('updateWithPluginValues %o', { cfg, overrides });219 // make sure every option returned from the plugins file220 // passes our validation functions221 config_1.default.validate(overrides, (errMsg) => {222 if (cfg.pluginsFile && cfg.projectRoot) {223 const relativePluginsPath = path_1.default.relative(cfg.projectRoot, cfg.pluginsFile);224 return errors_1.default.throw('PLUGINS_CONFIG_VALIDATION_ERROR', relativePluginsPath, errMsg);225 }226 return errors_1.default.throw('CONFIG_VALIDATION_ERROR', errMsg);227 });228 let originalResolvedBrowsers = cfg && cfg.resolved && cfg.resolved.browsers && lodash_1.default.cloneDeep(cfg.resolved.browsers);229 if (!originalResolvedBrowsers) {230 // have something to resolve with if plugins return nothing231 originalResolvedBrowsers = {232 value: cfg.browsers,233 from: 'default',234 };235 }236 const diffs = (0, return_deep_diff_1.default)(cfg, overrides, true);237 debug('config diffs %o', diffs);238 const userBrowserList = diffs && diffs.browsers && lodash_1.default.cloneDeep(diffs.browsers);239 if (userBrowserList) {240 debug('user browser list %o', userBrowserList);241 }242 // for each override go through243 // and change the resolved values of cfg244 // to point to the plugin245 if (diffs) {246 debug('resolved config before diffs %o', cfg.resolved);247 setPluginResolvedOn(cfg.resolved, diffs);248 debug('resolved config object %o', cfg.resolved);249 }250 // merge cfg into overrides251 const merged = lodash_1.default.defaultsDeep(diffs, cfg);252 debug('merged config object %o', merged);253 // the above _.defaultsDeep combines arrays,254 // if diffs.browsers = [1] and cfg.browsers = [1, 2]255 // then the merged result merged.browsers = [1, 2]256 // which is NOT what we want257 if (Array.isArray(userBrowserList) && userBrowserList.length) {258 merged.browsers = userBrowserList;259 merged.resolved.browsers.value = userBrowserList;260 }261 if (overrides.browsers === null) {262 // null breaks everything when merging lists263 debug('replacing null browsers with original list %o', originalResolvedBrowsers);264 merged.browsers = cfg.browsers;265 if (originalResolvedBrowsers) {266 merged.resolved.browsers = originalResolvedBrowsers;267 }268 }269 debug('merged plugins config %o', merged);270 return merged;271}272exports.updateWithPluginValues = updateWithPluginValues;273// combines the default configuration object with values specified in the274// configuration file like "cypress.json". Values in configuration file275// overwrite the defaults.276function resolveConfigValues(config, defaults, resolved = {}) {277 // pick out only known configuration keys278 return lodash_1.default279 .chain(config)280 .pick(config_1.default.getPublicConfigKeys())281 .mapValues((val, key) => {282 let r;283 const source = (s) => {284 return {285 value: val,286 from: s,287 };288 };289 r = resolved[key];290 if (r) {291 if (lodash_1.default.isObject(r)) {292 return r;293 }294 return source(r);295 }296 if (!(!lodash_1.default.isEqual(config[key], defaults[key]) && key !== 'browsers')) {297 // "browsers" list is special, since it is dynamic by default298 // and can only be overwritten via plugins file299 return source('default');300 }301 return source('config');302 }).value();303}304exports.resolveConfigValues = resolveConfigValues;305// instead of the built-in Node process, specify a path to 3rd party Node306const setNodeBinary = (obj, userNodePath, userNodeVersion) => {307 // if execPath isn't found we weren't executed from the CLI and should used the bundled node version.308 if (userNodePath && userNodeVersion && obj.nodeVersion !== 'bundled') {309 obj.resolvedNodePath = userNodePath;310 obj.resolvedNodeVersion = userNodeVersion;311 return obj;312 }313 obj.resolvedNodeVersion = process.versions.node;314 return obj;315};316exports.setNodeBinary = setNodeBinary;317function setScaffoldPaths(obj) {318 obj = lodash_1.default.clone(obj);319 debug('set scaffold paths');320 return scaffold_1.default.fileTree(obj)321 .then((fileTree) => {322 debug('got file tree');323 obj.scaffoldedFiles = fileTree;324 return obj;325 });326}327exports.setScaffoldPaths = setScaffoldPaths;328// async function329function setSupportFileAndFolder(obj, defaults) {330 if (!obj.supportFile) {331 return bluebird_1.default.resolve(obj);332 }333 obj = lodash_1.default.clone(obj);334 // TODO move this logic to find support file into util/path_helpers335 const sf = obj.supportFile;336 debug(`setting support file ${sf}`);337 debug(`for project root ${obj.projectRoot}`);338 return bluebird_1.default339 .try(() => {340 // resolve full path with extension341 obj.supportFile = exports.utils.resolveModule(sf);342 return debug('resolved support file %s', obj.supportFile);343 }).then(() => {344 if (!path_helpers_1.default.checkIfResolveChangedRootFolder(obj.supportFile, sf)) {345 return;346 }347 debug('require.resolve switched support folder from %s to %s', sf, obj.supportFile);348 // this means the path was probably symlinked, like349 // /tmp/foo -> /private/tmp/foo350 // which can confuse the rest of the code351 // switch it back to "normal" file352 obj.supportFile = path_1.default.join(sf, path_1.default.basename(obj.supportFile));353 return fs_1.fs.pathExists(obj.supportFile)354 .then((found) => {355 if (!found) {356 errors_1.default.throw('SUPPORT_FILE_NOT_FOUND', obj.supportFile, obj.configFile || defaults.configFile);357 }358 return debug('switching to found file %s', obj.supportFile);359 });360 }).catch({ code: 'MODULE_NOT_FOUND' }, () => {361 debug('support JS module %s does not load', sf);362 const loadingDefaultSupportFile = sf === path_1.default.resolve(obj.projectRoot, defaults.supportFile);363 return exports.utils.discoverModuleFile({364 filename: sf,365 isDefault: loadingDefaultSupportFile,366 projectRoot: obj.projectRoot,367 })368 .then((result) => {369 if (result === null) {370 const configFile = obj.configFile || defaults.configFile;371 return errors_1.default.throw('SUPPORT_FILE_NOT_FOUND', path_1.default.resolve(obj.projectRoot, sf), configFile);372 }373 debug('setting support file to %o', { result });374 obj.supportFile = result;375 return obj;376 });377 })378 .then(() => {379 if (obj.supportFile) {380 // set config.supportFolder to its directory381 obj.supportFolder = path_1.default.dirname(obj.supportFile);382 debug(`set support folder ${obj.supportFolder}`);383 }384 return obj;385 });386}387exports.setSupportFileAndFolder = setSupportFileAndFolder;388// set pluginsFile to an absolute path with the following rules:389// - do nothing if pluginsFile is falsey390// - look up the absolute path via node, so 'cypress/plugins' can resolve391// to 'cypress/plugins/index.js' or 'cypress/plugins/index.coffee'392// - if not found393// * and the pluginsFile is set to the default394// - and the path to the pluginsFile directory exists395// * assume the user doesn't need a pluginsFile, set it to false396// so it's ignored down the pipeline397// - and the path to the pluginsFile directory does not exist398// * set it to cypress/plugins/index.js, it will get scaffolded399// * and the pluginsFile is NOT set to the default400// - throw an error, because it should be there if the user401// explicitly set it402exports.setPluginsFile = bluebird_1.default.method((obj, defaults) => {403 if (!obj.pluginsFile) {404 return obj;405 }406 obj = lodash_1.default.clone(obj);407 const { pluginsFile, } = obj;408 debug(`setting plugins file ${pluginsFile}`);409 debug(`for project root ${obj.projectRoot}`);410 return bluebird_1.default411 .try(() => {412 // resolve full path with extension413 obj.pluginsFile = exports.utils.resolveModule(pluginsFile);414 return debug(`set pluginsFile to ${obj.pluginsFile}`);415 }).catch({ code: 'MODULE_NOT_FOUND' }, () => {416 debug('plugins module does not exist %o', { pluginsFile });417 const isLoadingDefaultPluginsFile = pluginsFile === path_1.default.resolve(obj.projectRoot, defaults.pluginsFile);418 return exports.utils.discoverModuleFile({419 filename: pluginsFile,420 isDefault: isLoadingDefaultPluginsFile,421 projectRoot: obj.projectRoot,422 })423 .then((result) => {424 if (result === null) {425 return errors_1.default.throw('PLUGINS_FILE_ERROR', path_1.default.resolve(obj.projectRoot, pluginsFile));426 }427 debug('setting plugins file to %o', { result });428 obj.pluginsFile = result;429 return obj;430 });431 }).return(obj);432});433function setParentTestsPaths(obj) {434 // projectRoot: "/path/to/project"435 // integrationFolder: "/path/to/project/cypress/integration"436 // componentFolder: "/path/to/project/cypress/components"437 // parentTestsFolder: "/path/to/project/cypress"438 // parentTestsFolderDisplay: "project/cypress"439 obj = lodash_1.default.clone(obj);440 const ptfd = (obj.parentTestsFolder = path_1.default.dirname(obj.integrationFolder));441 const prd = path_1.default.dirname(obj.projectRoot != null ? obj.projectRoot : '');442 obj.parentTestsFolderDisplay = path_1.default.relative(prd, ptfd);443 return obj;444}445exports.setParentTestsPaths = setParentTestsPaths;446function setAbsolutePaths(obj) {447 let pr;448 obj = lodash_1.default.clone(obj);449 // if we have a projectRoot450 pr = obj.projectRoot;451 if (pr) {452 // reset fileServerFolder to be absolute453 // obj.fileServerFolder = path.resolve(pr, obj.fileServerFolder)454 // and do the same for all the rest455 lodash_1.default.extend(obj, convertRelativeToAbsolutePaths(pr, obj));456 }457 return obj;458}459exports.setAbsolutePaths = setAbsolutePaths;460function setUrls(obj) {...
RouteHelpers.js
Source:RouteHelpers.js
...8 * @param absolutePaths9 * @param currentRoute10 * @param childRoutes11 */12 static setAbsolutePaths(absolutePaths, currentRoute, childRoutes) {13 if (currentRoute && currentRoute.path && childRoutes && _.isArray(childRoutes)) {14 let currentPaths = [...currentRoute.path];15 _.map(childRoutes, (route) => {16 if (route && _.isObject(route) && route.address) {17 if (_.isString(route.address)) {18 route.path = [route.address];19 } else if (_.isArray(route.address)) {20 route.path = _.clone(route.address);21 } else {22 throw new Error('Please provide route address.');23 }24 let paths = [];25 route.path.map((path, index) => {26 for (let j = 0; j < currentRoute.path.length; j++) {27 paths.push(`${currentRoute.path[j]}${path}`);28 }29 });30 route.path = paths;31 currentPaths = [...currentPaths, ...route.path];32 } else {33 throw Error('Route properties missing');34 }35 });36 currentRoute.path = [...currentPaths];37 absolutePaths.path = [...absolutePaths.path, ...currentRoute.path];38 _.map(childRoutes, (route) => {39 if (route && route.routes) {40 if(_.isArray(route.routes)){41 this.setAbsolutePaths(absolutePaths, route, route.routes);42 } else {43 throw Error('Child routes types should be an array.');44 }45 }46 });47 }48 }49 static setRoutes(config) {50 let routes = config.routes || [];51 routes = routes.map((route) => {52 // Set address53 if (_.isString(route.address)) {54 route.path = [route.address];55 } else if (_.isArray(route.address)) {56 route.path = _.clone(route.address);57 } else {58 throw new Error('Please provide route address.');59 }60 if (route.routes && !_.isEmpty(route.routes)) {61 if (_.isArray(route.routes)) {62 let absolutePaths = {path: []};63 this.setAbsolutePaths(absolutePaths, route, route.routes);64 route.path = _.clone(absolutePaths.path);65 } else {66 throw Error('Child routes types should be an array.');67 }68 }69 return {70 ...route,71 settings: {...config.settings, ...route.settings},72 stores: {...config.stores}73 };74 });75 return routes;76 }77 /**...
next.config.js
Source:next.config.js
...50 if (Array.isArray(config.optimization.minimizer)) {51 config.optimization.minimizer.push(new OptimizeCSSAssetsPlugin({}));52 }53 }54 const newAliasConfig = setAbsolutePaths(55 [ 'components', 'pages', 'layouts', 'utils', 'styles' ],56 config.resolve.alias57 );58 config.resolve.alias = newAliasConfig;59 return config;60 },61 cssModules: true,62 cssLoaderOptions: {63 localIdentName: '[local]___[hash:base64:3]'64 },65 generateBuildId: () => currentBuildId,66 [PHASE_PRODUCTION_BUILD]: {67 cssLoaderOptions: {68 localIdentName: '[hash:base64:8]'...
Using AI Code Generation
1cy.setAbsolutePaths();2Cypress.Commands.add('setAbsolutePaths', () => {3 Cypress.config('defaultCommandTimeout', 10000);4 Cypress.config('pageLoadTimeout', 30000);5 Cypress.config('requestTimeout', 5000);6 Cypress.config('responseTimeout', 30000);7});8{9}10module.exports = (on, config) => {11 config.defaultCommandTimeout = 10000;12 config.pageLoadTimeout = 30000;13 config.requestTimeout = 5000;14 config.responseTimeout = 30000;15 return config;16}17import './commands'18describe('Test', () => {19 it('should test', () => {20 cy.visit('/');21 });22});23{24 "env": {25 }26}27module.exports = (on, config) => {
Using AI Code Generation
1Cypress.config('pageLoadTimeout', 10000);2Cypress.config('defaultCommandTimeout', 10000);3Cypress.config('pageLoadTimeout', 10000);4Cypress.config('defaultCommandTimeout', 10000);5Cypress.config('pageLoadTimeout', 10000);6Cypress.config('defaultCommandTimeout', 10000);7Cypress.config('pageLoadTimeout', 10000);8Cypress.config('defaultCommandTimeout', 10000);9Cypress.config('pageLoadTimeout', 10000);10Cypress.config('defaultCommandTimeout', 10000);11Cypress.config('pageLoadTimeout', 10000);12Cypress.config('defaultCommandTimeout', 10000);13Cypress.config('pageLoadTimeout', 10000);14Cypress.config('defaultCommandTimeout', 10000);15Cypress.config('pageLoadTimeout', 10000);16Cypress.config('defaultCommandTimeout', 10000);17Cypress.config('pageLoadTimeout', 10000);18Cypress.config('defaultCommandTimeout', 10000);19Cypress.config('pageLoadTimeout', 10000);20Cypress.config('defaultCommandTimeout', 10000);21Cypress.config('pageLoadTimeout', 10000);22Cypress.config('defaultCommandTimeout', 10000);23Cypress.config('pageLoadTimeout', 10000);24Cypress.config('defaultCommandTimeout', 10000);25Cypress.config('pageLoadTimeout', 10000);26Cypress.config('defaultCommandTimeout', 10000);27Cypress.config('baseUrl
Using AI Code Generation
1describe('Set Absolute Paths', function() {2 it('Set Absolute Paths', function() {3 cy.setAbsolutePaths()4 })5})6Cypress.Commands.add('setAbsolutePaths', () => {7 cy.window().then(win => {8 })9})10Cypress.Commands.add('setAbsolutePaths', () => {11 cy.window().then(win => {12 })13})14Cypress.Commands.add('setAbsolutePaths', () => {15 cy.window().then(win => {16 })17})
Using AI Code Generation
1require('cypress-xpath')2describe('My First Test', function() {3 it('Does not do much!', function() {4 cy.get('input[name="q"]').type('Hello World')5 cy.get('input[name="btnK"]').click()6 cy.get('body').contains('Hello World').should('exist')7 cy.get('body').contains('Hello World').should('not.exist')8 })9})10{11}12{13}14{15}16{17}18{19}20{21}22{
Using AI Code Generation
1Cypress.Commands.add('setAbsolutePaths', (files) => {2 const absolutePaths = files.map((file) => {3 return path.join(__dirname, '..', file);4 });5 return absolutePaths;6});7Cypress.Commands.add('setAbsolutePaths', (files) => {8 const absolutePaths = files.map((file) => {9 return path.join(__dirname, '..', file);10 });11 return absolutePaths;12});13Cypress.Commands.add('setAbsolutePaths', (files) => {14 const absolutePaths = files.map((file) => {15 return path.join(__dirname, '..', file);16 });17 return absolutePaths;18});19Cypress.Commands.add('setAbsolutePaths', (files) => {20 const absolutePaths = files.map((file) => {21 return path.join(__dirname, '..', file);22 });23 return absolutePaths;24});25Cypress.Commands.add('setAbsolutePaths', (files) => {26 const absolutePaths = files.map((file) => {27 return path.join(__dirname, '..', file);28 });29 return absolutePaths;30});31Cypress.Commands.add('setAbsolutePaths', (files) => {32 const absolutePaths = files.map((file) => {33 return path.join(__dirname, '..', file);34 });35 return absolutePaths;36});37Cypress.Commands.add('setAbsolutePaths', (files) => {38 const absolutePaths = files.map((file) => {39 return path.join(__dirname, '..', file);40 });
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.
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.
Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.
Get 100 minutes of automation test minutes FREE!!