How to use getCurrentVersion method in Cypress

Best JavaScript code snippet using cypress

savegame.js

Source:savegame.js Github

copy

Full Screen

...30 /** @type {import("./savegame_typedefs").SavegameData} */31 this.currentData = this.getDefaultData();32 if (gamemode) this.currentData.gamemode = gamemode;33 assert(34 savegameInterfaces[Savegame.getCurrentVersion()],35 "Savegame interface not defined: " + Savegame.getCurrentVersion()36 );37 }38 //////// RW Proxy Impl //////////39 /**40 * @returns {any}41 */42 static getCurrentVersion() {43 return "ML01";44 }45 /**46 * @returns {typeof BaseSavegameInterface}47 */48 static getReaderClass() {49 return savegameInterfaces[Savegame.getCurrentVersion()];50 }51 /**52 * @returns {number}53 */54 getCurrentVersion() {55 return /** @type {typeof Savegame} */ (this.constructor).getCurrentVersion();56 }57 /**58 * Returns the savegames default data59 * @returns {import("./savegame_typedefs").SavegameData}60 */61 getDefaultData() {62 return {63 version: this.getCurrentVersion(),64 dump: null,65 stats: {},66 lastUpdate: Date.now(),67 gamemode: RegularGameMode.getId(),68 };69 }70 /**71 * Migrates the savegames data72 * @param {import("./savegame_typedefs").SavegameData} data73 */74 migrate(data) {75 if (data.version < 1000) {76 return ExplainedResult.bad("Can not migrate savegame, too old");77 }78 if (data.version === 1000) {79 SavegameInterface_V1001.migrate1000to1001(data);80 data.version = 1001;81 }82 if (data.version === 1001) {83 SavegameInterface_V1002.migrate1001to1002(data);84 data.version = 1002;85 }86 if (data.version === 1002) {87 SavegameInterface_V1003.migrate1002to1003(data);88 data.version = 1003;89 }90 if (data.version === 1003) {91 SavegameInterface_V1004.migrate1003to1004(data);92 data.version = 1004;93 }94 if (data.version === 1004) {95 SavegameInterface_V1005.migrate1004to1005(data);96 data.version = 1005;97 }98 if (data.version === 1005) {99 SavegameInterface_V1006.migrate1005to1006(data);100 data.version = 1006;101 }102 if (data.version === 1006) {103 SavegameInterface_V1007.migrate1006to1007(data);104 data.version = 1007;105 }106 if (data.version === 1007) {107 SavegameInterface_ML01.migrate1007toML01(data);108 data.version = "ML01";109 }110 return ExplainedResult.good();111 }112 /**113 * Verifies the savegames data114 * @param {import("./savegame_typedefs").SavegameData} data115 */116 verify(data) {117 if (!data.dump) {118 // Well, guess that works119 return ExplainedResult.good();120 }121 if (!this.getDumpReaderForExternalData(data).validate()) {122 return ExplainedResult.bad("dump-reader-failed-validation");123 }124 return ExplainedResult.good();125 }126 //////// Subclasses interface ////////127 /**128 * Returns if this game can be saved on disc129 * @returns {boolean}130 */131 isSaveable() {132 return true;133 }134 /**135 * Returns the statistics of the savegame136 * @returns {import("./savegame_typedefs").SavegameStats}137 */138 getStatistics() {139 return this.currentData.stats;140 }141 /**142 * Returns the *real* last update of the savegame, not the one of the metadata143 * which could also be the servers one144 */145 getRealLastUpdate() {146 return this.currentData.lastUpdate;147 }148 /**149 * Returns if this game has a serialized game dump150 */151 hasGameDump() {152 return !!this.currentData.dump && this.currentData.dump.entities.length > 0;153 }154 /**155 * Returns the current game dump156 * @returns {import("./savegame_typedefs").SerializedGame}157 */158 getCurrentDump() {159 return this.currentData.dump;160 }161 /**162 * Returns a reader to access the data163 * @returns {BaseSavegameInterface}164 */165 getDumpReader() {166 if (!this.currentData.dump) {167 logger.warn("Getting reader on null-savegame dump");168 }169 const cls = /** @type {typeof Savegame} */ (this.constructor).getReaderClass();170 return new cls(this.currentData);171 }172 /**173 * Returns a reader to access external data174 * @returns {BaseSavegameInterface}175 */176 getDumpReaderForExternalData(data) {177 assert(data.version, "External data contains no version");178 return getSavegameInterface(data);179 }180 ///////// Public Interface ///////////181 /**182 * Updates the last update field so we can send the savegame to the server,183 * WITHOUT Saving!184 */185 setLastUpdate(time) {186 this.currentData.lastUpdate = time;187 }188 /**189 *190 * @param {import("../game/root").GameRoot} root191 */192 updateData(root) {193 // Construct a new serializer194 const serializer = new SavegameSerializer();195 // let timer = performance.now();196 const dump = serializer.generateDumpFromGameRoot(root);197 if (!dump) {198 return false;199 }200 const shadowData = Object.assign({}, this.currentData);201 shadowData.dump = dump;202 shadowData.lastUpdate = new Date().getTime();203 shadowData.version = this.getCurrentVersion();204 // @ts-ignore205 shadowData.gamemode = root.gameMode.constructor.getId();206 const reader = this.getDumpReaderForExternalData(shadowData);207 // Validate (not in prod though)208 if (!G_IS_RELEASE) {209 const validationResult = reader.validate();210 if (!validationResult) {211 return false;212 }213 }214 // Save data215 this.currentData = shadowData;216 }217 /**218 * Writes the savegame as well as its metadata219 */220 writeSavegameAndMetadata() {221 return this.writeAsync().then(() => this.saveMetadata());222 }223 /**224 * Updates the savegames metadata225 */226 saveMetadata() {227 this.metaDataRef.lastUpdate = new Date().getTime();228 this.metaDataRef.version = this.getCurrentVersion();229 if (!this.hasGameDump()) {230 this.metaDataRef.level = 0;231 } else {232 this.metaDataRef.level = this.currentData.dump.hubGoals.level;233 }234 return this.app.savegameMgr.writeAsync();235 }236 /**237 * @see ReadWriteProxy.writeAsync238 * @returns {Promise<any>}239 */240 writeAsync() {241 if (G_IS_DEV && globalConfig.debug.disableSavegameWrite) {242 return Promise.resolve();...

Full Screen

Full Screen

initTo.js

Source:initTo.js Github

copy

Full Screen

1const bunyan = require('bunyan');2const { expect } = require('code');3const { afterEach, beforeEach, describe, it } = exports.lab = require('lab').script();4const proxyquire = require('proxyquire').noCallThru();5const sinon = require('sinon');6const logTemplate = bunyan.createLogger({7 name: 'test'8});9describe('arango/initTo', () => {10 let bunyanMock;11 let ensureDb;12 let getCurrentVersion;13 let init;14 let initTo;15 let migration1;16 let migration2;17 beforeEach(() => {18 bunyanMock = sinon.mock(logTemplate);19 ensureDb = sinon.stub().resolves();20 getCurrentVersion = sinon.stub();21 migration1 = {22 rollback: sinon.stub().resolves(),23 setup: sinon.stub().resolves(),24 verify: sinon.stub().resolves()25 };26 migration2 = {27 rollback: sinon.stub().resolves(),28 setup: sinon.stub().resolves(),29 verify: sinon.stub().resolves()30 };31 initTo = proxyquire(32 '../../../../src/arango/init/initTo',33 {34 './ensureDb': ensureDb,35 './getCurrentVersion': getCurrentVersion,36 '../../logger': { get: () => logTemplate },37 '../v1': {}38 });39 });40 afterEach(() => {41 bunyanMock.verify();42 bunyanMock.restore();43 });44 it('exists', () => {45 expect(initTo).to.exist();46 });47 it('is a function', () => {48 expect(initTo).to.be.a.function();49 });50 describe('init to 1 from 0', () => {51 beforeEach(() => {52 getCurrentVersion.resolves(0);53 initTo = proxyquire(54 '../../../../src/arango/init/initTo',55 {56 './ensureDb': ensureDb,57 './getCurrentVersion': getCurrentVersion,58 '../../logger': { get: () => logTemplate },59 '../v1': migration160 });61 init = initTo(1);62 });63 it('exists', () => {64 expect(init).to.exist();65 });66 it('is a function', () => {67 expect(init).to.be.a.function();68 });69 describe('successful', () => {70 beforeEach(async () => {71 result = await init();72 });73 it('calls ensureDb', () => {74 expect(ensureDb.called).to.be.true();75 });76 it('calls migration.setup', () => {77 expect(migration1.setup.called).to.be.true();78 });79 it('calls migration.verify', () => {80 expect(migration1.verify.called).to.be.true();81 });82 it('does not call rollback', () => {83 expect(migration1.rollback.called).to.be.false();84 });85 });86 describe('setup rejects', () => {87 let error;88 beforeEach(async () => {89 migration1.setup.rejects(new Error());90 bunyanMock.expects('error');91 try {92 await init();93 } catch (e) {94 error = e;95 }96 });97 it('throws', () => {98 expect(error).to.exist();99 expect(error).to.be.an.instanceOf(Error);100 })101 it('does not call verify', () => {102 expect(migration1.verify.called).to.be.false();103 });104 it('does not call rollback', () => {105 expect(migration1.rollback.called).to.be.false();106 });107 });108 describe('verify rejects', () => {109 let error;110 beforeEach(async () => {111 migration1.verify.rejects(new Error());112 bunyanMock.expects('error');113 try {114 await init();115 } catch (e) {116 error = e;117 }118 });119 it('calls rollback', () => {120 expect(migration1.rollback.called).to.be.true();121 });122 });123 });124 describe('init to 2 from 0', () => {125 beforeEach(() => {126 getCurrentVersion.resolves(0);127 initTo = proxyquire(128 '../../../../src/arango/init/initTo',129 {130 './ensureDb': ensureDb,131 './getCurrentVersion': getCurrentVersion,132 '../../logger': { get: () => logTemplate },133 '../v1': migration1,134 '../v2': migration2135 });136 init = initTo(2);137 });138 describe('successful', () => {139 beforeEach(async () => {140 result = await init();141 });142 it('calls ensureDb', () => {143 expect(ensureDb.called).to.be.true();144 });145 it('calls migration.setup', () => {146 expect(migration1.setup.called).to.be.true();147 expect(migration2.setup.called).to.be.true();148 });149 it('calls migration.verify', () => {150 expect(migration1.verify.called).to.be.true();151 expect(migration2.verify.called).to.be.true();152 });153 it('does not call rollback', () => {154 expect(migration1.rollback.called).to.be.false();155 expect(migration2.rollback.called).to.be.false();156 });157 });158 describe('v2 setup fails', () => {159 let error;160 beforeEach(async () => {161 migration2.setup.rejects(new Error());162 bunyanMock.expects('error');163 try {164 result = await init();165 } catch (e) {166 error = e;167 }168 });169 it('calls each setup a maximum of once', () => {170 expect(migration1.setup.calledOnce).to.be.true();171 expect(migration2.setup.calledOnce).to.be.true();172 });173 it('calls migration.setup', () => {174 expect(migration1.setup.called).to.be.true();175 expect(migration2.setup.called).to.be.true();176 });177 it('calls migration.verify on migration 1 only', () => {178 expect(migration1.verify.called).to.be.true();179 expect(migration2.verify.called).to.be.false();180 });181 it('does call rollback only for migration 1', () => {182 expect(migration1.rollback.called).to.be.true();183 expect(migration2.rollback.called).to.be.false();184 });185 });186 describe('v2 verify fails and rollback fails', () => {187 let error;188 beforeEach(async () => {189 migration2.verify.rejects(new Error());190 migration2.rollback.rejects(new Error);191 bunyanMock.expects('error');192 try {193 result = await init();194 } catch (e) {195 error = e;196 }197 });198 it('calls migration.setup', () => {199 expect(migration1.setup.called).to.be.true();200 expect(migration2.setup.called).to.be.true();201 });202 it('calls migration.verify', () => {203 expect(migration1.verify.called).to.be.true();204 expect(migration2.verify.called).to.be.true();205 });206 it('calls rollback on migration 2', () => {207 expect(migration1.rollback.called).to.be.false();208 expect(migration2.rollback.called).to.be.true();209 });210 });211 });212 describe('init to 1 from 1', () => {213 beforeEach(async () => {214 getCurrentVersion.resolves(1);215 initTo = proxyquire(216 '../../../../src/arango/init/initTo',217 {218 './ensureDb': ensureDb,219 './getCurrentVersion': getCurrentVersion,220 '../../logger': { get: () => logTemplate },221 '../v1': migration1222 });223 init = initTo(1);224 result = await init();225 });226 it('calls ensureDb', () => {227 expect(ensureDb.called).to.be.true();228 });229 it('does not call migration.setup', () => {230 expect(migration1.setup.called).to.be.false();231 });232 it('does not call migration.verify', () => {233 expect(migration1.verify.called).to.be.false();234 });235 it('does not call rollback', () => {236 expect(migration1.rollback.called).to.be.false();237 });238 });...

Full Screen

Full Screen

migrate.test.js

Source:migrate.test.js Github

copy

Full Screen

...51 jest.clearAllMocks();52 });53 test('getCurrentVersion', async () => {54 db.query.mockReturnValue({ all: jest.fn().mockResolvedValueOnce([{ version: '1.6.2' }]) });55 const version = await getCurrentVersion(db);56 expect(db.query).toHaveBeenCalledWith('SELECT * FROM SchemaHistory ORDER BY createdAt DESC LIMIT 1');57 expect(version).toEqual('1.6.2');58 });59 test('getLoadVersion', () => {60 const version = getLoadVersion();61 expect(version).toHaveProperty('version');62 expect(version.version).toEqual(expect.stringMatching(/^\d+\.\d+\.\d+$/));63 });64 describe('requiresMigration', () => {65 test('compatible versions do not require migration', () => {66 expect(requiresMigration('1.9.1', '1.9.2')).toBeFalsy();67 });68 test('minor version difference requires migration', () => {69 expect(requiresMigration('1.9.1', '1.10.1')).toBeTruthy();...

Full Screen

Full Screen

CustomerAggregate.test.js

Source:CustomerAggregate.test.js Github

copy

Full Screen

...10it('should return state with version 0', () => {11 // we want no event history to test this case12 const storedEvents = new Set()13 let state = customer.loadFromHistory(storedEvents)14 let version = customer.getCurrentVersion(state)15 expect(version).toBe(0)16})17it('should register a customer', () => {18 // we want no event history to test this case19 const storedEvents = new Set()20 // prepare aggregate with no event history (new aggregate)21 let state = customer.loadFromHistory(storedEvents)22 let version = customer.getCurrentVersion(state)23 let uncommittedChanges = customer.getUncommittedChanges(state)24 expect(version).toBe(0)25 expect(uncommittedChanges.size).toBe(0)26 // register a customer27 state = customer.register(state, CUSTOMER_1_ID, CUSTOMER_1_NAME, CUSTOMER_1_EMAIL, CUSTOMER_1_PASSWORD)28 version = customer.getCurrentVersion(state)29 expect(state.created).toBe(0)30 expect(state.active).toBe(0)31 expect(state.customerId).toBe(CUSTOMER_1_ID)32 expect(state.name).toBe(CUSTOMER_1_NAME)33 expect(state.email).toBe(CUSTOMER_1_EMAIL)34 expect(state.password).toBe(CUSTOMER_1_PASSWORD)35 // new changes are yet to be written to Event Store36 // therefore aggreagate version must not change37 // and applied change must be added to uncommittedChanges set38 expect(version).toBe(0)39 expect(uncommittedChanges.size).toBe(1)40})41it('should create a new customer', () => {42 // we want no event history to test this case43 const storedEvents = new Set()44 // prepare aggregate with no event history (new aggregate)45 let state = customer.loadFromHistory(storedEvents)46 let version = customer.getCurrentVersion(state)47 let uncommittedChanges = customer.getUncommittedChanges(state)48 expect(version).toBe(0)49 expect(uncommittedChanges.size).toBe(0)50 // create new customer51 state = customer.create(state, CUSTOMER_1_ID, CUSTOMER_1_NAME, CUSTOMER_1_EMAIL, CUSTOMER_1_PASSWORD)52 version = customer.getCurrentVersion(state)53 expect(state.created).toBe(1)54 expect(state.active).toBe(1)55 expect(state.customerId).toBe(CUSTOMER_1_ID)56 expect(state.name).toBe(CUSTOMER_1_NAME)57 expect(state.email).toBe(CUSTOMER_1_EMAIL)58 expect(state.password).toBe(CUSTOMER_1_PASSWORD)59 // new changes are yet to be written to Event Store60 // therefore aggreagate version must not change61 // and applied change must be added to uncommittedChanges set62 expect(version).toBe(0)63 expect(uncommittedChanges.size).toBe(1)64})65it('should throw an error on create for an existing customer aggregate', () => {66 // create event history (that would be loaded from event store in real application)67 const storedEvents = new Set()68 storedEvents.add(CustomerCreated(CUSTOMER_1_ID, CUSTOMER_1_NAME, CUSTOMER_1_EMAIL, CUSTOMER_1_PASSWORD))69 // prepare aggregate with no event history (new aggregate)70 let state = customer.loadFromHistory(storedEvents)71 let version = customer.getCurrentVersion(state)72 let uncommittedChanges = customer.getUncommittedChanges(state)73 expect(version).toBe(1)74 expect(uncommittedChanges.size).toBe(0)75 // create new customer method on existing customer should throw an error76 expect(() => {77 customer.create(state, CUSTOMER_1_ID, CUSTOMER_1_NAME, CUSTOMER_1_EMAIL, CUSTOMER_1_PASSWORD)78 }).toThrow('can not create same customer more than once')79})80it('should update an existing customer aggregate', () => {81 // create event history (that would be loaded from event store in real application)82 const storedEvents = new Set()83 storedEvents.add(CustomerCreated(CUSTOMER_1_ID, CUSTOMER_1_NAME, CUSTOMER_1_EMAIL, CUSTOMER_1_PASSWORD))84 // prepare aggregate with no event history (new aggregate)85 let state = customer.loadFromHistory(storedEvents)86 let version = customer.getCurrentVersion(state)87 let uncommittedChanges = customer.getUncommittedChanges(state)88 expect(version).toBe(1)89 expect(uncommittedChanges.size).toBe(0)90 customer.update(state, CUSTOMER_1_NAME_UPDATED)91 expect(state.customerId).toBe(CUSTOMER_1_ID)92 expect(state.name).toBe(CUSTOMER_1_NAME_UPDATED)93})94it('should throw an error on updating a non-existing customer aggregate', () => {95 // create event history (that would be loaded from event store in real application)96 const storedEvents = new Set()97 // prepare aggregate with no event history (new aggregate)98 let state = customer.loadFromHistory(storedEvents)99 let version = customer.getCurrentVersion(state)100 let uncommittedChanges = customer.getUncommittedChanges(state)101 expect(version).toBe(0)102 expect(uncommittedChanges.size).toBe(0)103 // create new customer method on existing customer should throw an error104 expect(() => {105 customer.update(state, 'Test Customer Updated')106 }).toThrow("can not update customer that doesn't exist")107})108it('should deactivate an existing customer aggregate', () => {109 // create event history (that would be loaded from event store in real application)110 const storedEvents = new Set()111 storedEvents.add(CustomerCreated(CUSTOMER_1_ID, 'Test Customer', CUSTOMER_1_EMAIL, CUSTOMER_1_PASSWORD))112 // prepare aggregate with no event history (new aggregate)113 let state = customer.loadFromHistory(storedEvents)114 let version = customer.getCurrentVersion(state)115 let uncommittedChanges = customer.getUncommittedChanges(state)116 expect(version).toBe(1)117 expect(uncommittedChanges.size).toBe(0)118 customer.deactivate(state)119 expect(state.customerId).toBe(CUSTOMER_1_ID)120 expect(state.name).toBe('Test Customer')121 expect(state.deactivated).toBeTruthy()122})123it('should reactivate an existing customer aggregate', () => {124 // create event history (that would be loaded from event store in real application)125 const storedEvents = new Set()126 storedEvents.add(CustomerCreated(CUSTOMER_1_ID, 'Test Customer', CUSTOMER_1_EMAIL, CUSTOMER_1_PASSWORD))127 // prepare aggregate with no event history (new aggregate)128 let state = customer.loadFromHistory(storedEvents)129 let version = customer.getCurrentVersion(state)130 let uncommittedChanges = customer.getUncommittedChanges(state)131 expect(version).toBe(1)132 expect(uncommittedChanges.size).toBe(0)133 customer.deactivate(state)134 expect(state.customerId).toBe(CUSTOMER_1_ID)135 expect(state.name).toBe('Test Customer')136 expect(state.deactivated).toBeTruthy()137 customer.reactivate(state)138 expect(state.customerId).toBe(CUSTOMER_1_ID)139 expect(state.name).toBe('Test Customer')140 expect(state.deactivated).toBeUndefined()...

Full Screen

Full Screen

welcome.js

Source:welcome.js Github

copy

Full Screen

...8 var LAST_VERSION_KEY = "welcomemod:lastversion"9 , SHOULD_SHOW_WELCOME_KEY = "welcomemode:show_welcome"10 , restoreData = null;11 12 function getCurrentVersion(){13 return chrome.runtime.getManifest().version;14 }15 16 function getWelcomeUrl(){17 return WELCOME_URL.replace("{VERSION}", getCurrentVersion());18 }19 20 function restoreBrowserAction(){21 console.log("Restore data is", restoreData);22 23 var badgeText = restoreData.badgeText ? restoreData.badgeText : "";24 if(badgeText == BADGE_TEXT){25 badgeText = "";26 }27 chrome.browserAction.setBadgeText({28 text: badgeText29 });30 31 if(restoreData.popup){ 32 chrome.browserAction.setPopup({33 popup: restoreData.popup34 }); 35 }36 37 restoreData = null; 38 }39 40 function needShowWelcome(){41 if(!localStorage[LAST_VERSION_KEY]){42 localStorage[LAST_VERSION_KEY] = getCurrentVersion();43 //localStorage[SHOULD_SHOW_WELCOME_KEY] = "1";44 } 45 else{46 var currentVersion = getCurrentVersion();47 if(localStorage[LAST_VERSION_KEY] != currentVersion){48 localStorage[SHOULD_SHOW_WELCOME_KEY] = "1";49 localStorage[LAST_VERSION_KEY] = currentVersion;50 }51 } 52 53 return localStorage[SHOULD_SHOW_WELCOME_KEY] === "1";54 } 55 56 chrome.runtime.onInstalled.addListener(function(info){57 if(info.reason == "update"){58 localStorage[SHOULD_SHOW_WELCOME_KEY] = "1";59 }60 });...

Full Screen

Full Screen

npm-release

Source:npm-release Github

copy

Full Screen

...18var msg = function () {19 console.log([].slice.call(arguments).join(' ').blue);20};21var done = function () {22 success('Released new version ' + getCurrentVersion() + ' successfully.');23 process.exit(0);24};25var getPkg = function () {26 var pkg;27 try {28 pkg = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), './package.json')));29 } catch(e) {30 error('Could not open a package.json.');31 }32 return pkg;33};34var getCurrentVersion = function () {35 return getPkg().version;36};37var oldVersion = getCurrentVersion(),38 message = argv.m || argv.message;39if (!oldVersion) error('No version in package.json found.');40if (!version) error('No version supplied.');41// Run npm verison (tags & commits)42msg('Updating version...');43// %s is npm version variable: https://npmjs.org/doc/version.html44var npm = spawn('npm', ['version', version, '-m', message || "Release v%s."]);45npm.stdout.pipe(process.stdout);46npm.stderr.pipe(process.stderr);47npm.on('close', function (code) {48 if (code !== 0) return error('npm version. Exiting.');49 success('Version bumped from', oldVersion, 'to', getCurrentVersion());50 msg('Pushing...');51 // Run git-release (tag & push)52 var release = spawn('sh', [releasePath, getCurrentVersion()]);53 release.stdout.pipe(process.stdout);54 release.stderr.pipe(process.stderr);55 release.on('close', function (code) {56 if (code !== 0) return error('git-release. Exiting.');57 success('Pushed.');58 if (getPkg().private) {59 msg('Publish to npm cancelled, this is a private repo.');60 return done();61 }62 msg('Publishing to npm...');63 // Publish to npm64 var publish = spawn('npm', ['publish']);65 publish.stdout.pipe(process.stdout);66 publish.stderr.pipe(process.stderr);...

Full Screen

Full Screen

configController.js

Source:configController.js Github

copy

Full Screen

...19 data: respuesta,20 message: ""21 }22 */23function getCurrentVersion(_x, _x2) {24 return _getCurrentVersion.apply(this, arguments);25}26function _getCurrentVersion() {27 _getCurrentVersion = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(req, res) {28 var RESPONSE, _RESPONSE;29 return regeneratorRuntime.wrap(function _callee$(_context) {30 while (1) {31 switch (_context.prev = _context.next) {32 case 0:33 _context.prev = 0;34 RESPONSE = {35 status: true,36 version: process.env.APPVERSION37 };38 return _context.abrupt("return", res.json(RESPONSE));39 case 5:40 _context.prev = 5;...

Full Screen

Full Screen

WhatsNew.js

Source:WhatsNew.js Github

copy

Full Screen

...16 $('#whatsnew').on('hidden.bs.modal', function () {17 // next time popup is open, by default we will see everything18 self.prepare(false);19 });20 if (!self.getCurrentVersion() && BR.Util.localStorageAvailable()) {21 localStorage.setItem('changelogVersion', self.getLatestVersion());22 }23 self.prepare(self.hasNewVersions());24 if (self.hasNewVersions()) {25 self.dismissableMessage.showInfo(i18next.t('whatsnew.new-version'));26 document.getElementsByClassName('version')[0].classList.add('version-new');27 }28 },29 getLatestVersion: function () {30 return BR.changelog.match('<h2 id="(.*)">')[1];31 },32 getCurrentVersion: function () {33 if (!BR.Util.localStorageAvailable()) return null;34 return localStorage.getItem('changelogVersion');35 },36 hasNewVersions: function () {37 return this.getCurrentVersion() && this.getCurrentVersion() !== this.getLatestVersion();38 },39 prepare: function (newOnly) {40 if (newOnly === this.newOnly) {41 // do not rebuild modal content unnecessarily42 return;43 }44 this.newOnly = newOnly;45 var container = document.querySelector('#whatsnew .modal-body');46 var cl = BR.changelog;47 if (newOnly && this.getCurrentVersion()) {48 var head = '<h2 id="' + this.getCurrentVersion() + '">';49 var idx = cl.indexOf(head);50 if (idx >= 0) cl = cl.substring(0, idx);51 }52 container.innerHTML = cl;53 },...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe("My First Test", () => {2 it("Does not do much!", () => {3 cy.getCurrentVersion().then((version) => {4 console.log(version);5 });6 });7});8Cypress.Commands.add("getCurrentVersion", () => {9 return cy.request({10 headers: {11 },12 });13});

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.runs[0].browser.name)7 console.log(results.runs[0].browser.version)8 console.log(results.runs[0].browser.osName)9 console.log(results.runs[0].browser.osVersion)10 console.log(results.runs[0].browser.displayName)11 console.log(results.runs[0].browser.path)12 console.log(results.runs[0].browser.family)13 console.log(results.runs[0].browser.isHeadless)14 console.log(results.runs[0].browser.isHeaded)15 console.log(results.runs[0].browser.is64)16 console.log(results.runs[0].browser.is32)17})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Get current version of Cypress', () => {2 it('should get current version of Cypress', () => {3 cy.getCurrentVersion().then((version) => {4 expect(version).to.eq('4.12.1')5 })6 })7})8Cypress.Commands.add('getCurrentVersion', () => {9 })10})11module.exports = (on, config) => {12 on('task', {13 getCurrentVersion() {14 return require('../../package.json').devDependencies.cypress15 },16 })17}

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Cypress test', () => {2 it('test', () => {3 cy.getCurrentVersion().then((version) => {4 console.log(version);5 });6 });7});8Cypress.Commands.add('getCurrentVersion', () => {9 return cy.request({10 headers: {11 },12 }).then((response) => {13 return response.body;14 });15});

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.getCurrentVersion().then((version)=>{2 cy.log(version);3})4cy.getCurrentVersion().then((version)=>{5 cy.log(version);6})7Cypress.Commands.add('getCurrentVersion',()=>{8 return Cypress.env('version');9});10{11 "env": {12 }13}14{15 "env": {16 }17}18Cypress.Commands.add('getCurrentVersion',()=>{19 return Cypress.env('version');20});21Cypress.Commands.add('updateVersion',()=>{22 Cypress.env('version',Cypress.env('newVersion'));23});24cy.getCurrentVersion().then((version)=>{25 cy.log(version);26})27cy.updateVersion();28cy.getCurrentVersion().then((version)=>{29 cy.log(version);30})31Cypress.Commands.add('getCurrentVersion',()=>{32 return Cypress.env('version');33});34Cypress.Commands.add('updateVersion',()=>{35 Cypress.env('version',Cypress.env('newVersion'));36});37Cypress.Commands.add('resetVersion',()=>{38 Cypress.env('version','1.0.0');39});40cy.getCurrentVersion().then((version)=>{41 cy.log(version);42})43cy.updateVersion();44cy.getCurrentVersion().then((version)=>{45 cy.log(version);46})47cy.resetVersion();48cy.getCurrentVersion().then((version)=>{49 cy.log(version);50})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Cypress Demo', function() {2 it('getCurrentVersion', function() {3 cy.on('window:alert', (str) => {4 expect(str).to.equal('Cypress version is 3.4.0')5 })6 cy.window().then(win => {7 win.alert('Cypress version is ' + win.Cypress.version)8 })9 })10})11describe('Cypress Demo', function() {12 it('getCurrentVersion', function() {13 cy.on('window:alert', (str) => {14 expect(str).to.equal('Cypress version is 3.4.0')15 })16 cy.window().then(win => {17 win.alert('Cypress version is ' + win.Cypress.version)18 })19 })20})21describe('Cypress Demo', function() {22 it('getCurrentVersion', function() {23 cy.on('window:alert', (str) => {24 expect(str).to.equal('Cypress version is 3.4.0')25 })26 cy.window().then(win => {27 win.alert('Cypress version is ' + win.Cypress.version)28 })29 })30})31describe('Cypress Demo', function() {32 it('getCurrentVersion', function() {33 cy.on('window:alert', (str) => {34 expect(str).to.equal('Cypress version is 3.4.0')35 })36 cy.window().then(win => {37 win.alert('Cypress version is ' + win.Cypress.version)38 })39 })

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.getCurrentVersion()2### cy.getCurrentVersion()3### cy.getCypressVersion()4### cy.getChromeVersion()5### cy.getElectronVersion()6### cy.getFirefoxVersion()7### cy.getEdgeVersion()8### cy.getBrowserVersion()9### cy.getBrowserName()10### cy.getBrowserMajorVersion()11### cy.getBrowserMinorVersion()12### cy.getBrowserPatchVersion()13### cy.getBrowserBuildVersion()14### cy.getBrowserFullVersion()15### cy.getBrowserInfo()16#### on('task', { getCurrentVersion })17#### on('task', { getCypressVersion })18#### on('task', { getChromeVersion })

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getCurrentVersion } = require('@cypress/version')2const version = getCurrentVersion()3console.log(version)4describe('Test', () => {5 it('version', () => {6 const { getCurrentVersion } = require('@cypress/version')7 const version = getCurrentVersion()8 console.log(version)9 })10})11module.exports = (on, config) => {12 on('task', {13 logVersion () {14 const { getCurrentVersion } = require('@cypress/version')15 const version = getCurrentVersion()16 console.log(version)17 },18 })19}20describe('Test', () => {21 it('version', () => {22 cy.task('logVersion')23 })24})25module.exports = (on, config) => {26 on('task', {27 logVersion () {28 const { getCurrentVersion } = require('@cypress/version')29 const version = getCurrentVersion()30 console.log(version)31 },32 })33}34Cypress.Commands.add('logVersion', () => {35 cy.task('logVersion')36})37Cypress.Commands.add('logVersion', () => {38 cy.task('logVersion')39})40declare namespace Cypress {41 interface Chainable {42 * cy.logVersion()43 logVersion(): Chainable<Element>44 }45}

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.getCurrentVersion().then((version) => {2 cy.log(version);3});4"scripts": {5}6"scripts": {7}8"scripts": {9}10"scripts": {11}12"scripts": {13}14"scripts": {15}16"scripts": {17}18"scripts": {19}

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