Best JavaScript code snippet using appium
integration-deduping.js
Source:integration-deduping.js
...7 // A@2.0.1 -> B@2.0.08 // B@1.0.09 // should result in B@2.0.0 not flattened10 return runInstall({}, 'install-should-dedupe-avoiding-conflicts-0', async config => {11 expect(await getPackageVersion(config, 'dep-b')).toEqual('1.0.0');12 expect(await getPackageVersion(config, 'dep-a/dep-b')).toEqual('2.0.0');13 });14});15test.concurrent('install should dedupe dependencies avoiding conflicts 1', (): Promise<void> => {16 // A@2.0.1 -> B@2.0.017 // should result in B@2.0.0 flattened18 return runInstall({}, 'install-should-dedupe-avoiding-conflicts-1', async config => {19 expect(await getPackageVersion(config, 'dep-b')).toEqual('2.0.0');20 expect(await getPackageVersion(config, 'dep-a')).toEqual('2.0.1');21 });22});23test.concurrent('install should dedupe dependencies avoiding conflicts 2', (): Promise<void> => {24 // A@2 -> B@2 -> C@225 // -> D@126 // B@1 -> C@127 // should become28 // A@229 // A@2 -> B@230 // A@2 -> C@231 // D@132 // C@133 // B@134 return runInstall({}, 'install-should-dedupe-avoiding-conflicts-2', async config => {35 expect(await getPackageVersion(config, 'dep-a')).toEqual('2.0.0');36 expect(await getPackageVersion(config, 'dep-a/dep-b')).toEqual('2.0.0');37 expect(await getPackageVersion(config, 'dep-c')).toEqual('1.0.0');38 expect(await getPackageVersion(config, 'dep-d')).toEqual('1.0.0');39 expect(await getPackageVersion(config, 'dep-b')).toEqual('1.0.0');40 expect(await getPackageVersion(config, 'dep-a/dep-c')).toEqual('2.0.0');41 });42});43test.concurrent('install should dedupe dependencies avoiding conflicts 3', (): Promise<void> => {44 // A@2 -> B@2 -> C@245 // -> D@146 // -> C@147 // should become48 // A@249 // B@2 -> C@250 // C@151 // D@152 return runInstall({}, 'install-should-dedupe-avoiding-conflicts-3', async config => {53 expect(await getPackageVersion(config, 'dep-a')).toEqual('2.0.0');54 expect(await getPackageVersion(config, 'dep-c')).toEqual('1.0.0');55 expect(await getPackageVersion(config, 'dep-d')).toEqual('1.0.0');56 expect(await getPackageVersion(config, 'dep-b')).toEqual('2.0.0');57 expect(await getPackageVersion(config, 'dep-b/dep-c')).toEqual('2.0.0');58 });59});60test.concurrent('install should dedupe dependencies avoiding conflicts 4', (): Promise<void> => {61 // A@2 -> B@2 -> D@1 -> C@262 //63 // -> C@164 // should become65 // A@266 // D@1 -> C@267 // C@168 // B@269 return runInstall({}, 'install-should-dedupe-avoiding-conflicts-4', async config => {70 expect(await getPackageVersion(config, 'dep-a')).toEqual('2.0.0');71 expect(await getPackageVersion(config, 'dep-c')).toEqual('1.0.0');72 expect(await getPackageVersion(config, 'dep-d')).toEqual('1.0.0');73 expect(await getPackageVersion(config, 'dep-d/dep-c')).toEqual('2.0.0');74 expect(await getPackageVersion(config, 'dep-b')).toEqual('2.0.0');75 });76});77test.concurrent('install should dedupe dependencies avoiding conflicts 5', (): Promise<void> => {78 // A@1 -> B@179 // C@1 -> D@1 -> A@2 -> B@280 // should become81 // A@182 // B@183 // C@184 // D@1 -> A@285 // -> B@286 return runInstall({}, 'install-should-dedupe-avoiding-conflicts-5', async config => {87 expect(await getPackageVersion(config, 'dep-a')).toEqual('1.0.0');88 expect(await getPackageVersion(config, 'dep-b')).toEqual('1.0.0');89 expect(await getPackageVersion(config, 'dep-c')).toEqual('1.0.0');90 expect(await getPackageVersion(config, 'dep-d')).toEqual('1.0.0');91 expect(await getPackageVersion(config, 'dep-d/dep-a')).toEqual('2.0.0');92 expect(await getPackageVersion(config, 'dep-d/dep-b')).toEqual('2.0.0');93 });94});95test.concurrent('install should dedupe dependencies avoiding conflicts 6 (jest/jest-runtime case)', (): Promise<96 void,97> => {98 // C@1 -> D@1 -> E@199 // B@1 -> C@1 -> D@1 -> E@1100 // D@2101 // E@2102 // should become103 // C@1 -> D@1104 // -> E@1105 // B@1106 // D@2107 // E@2108 return runInstall({}, 'install-should-dedupe-avoiding-conflicts-6', async (config): Promise<void> => {109 expect(await getPackageVersion(config, 'dep-b')).toEqual('1.0.0');110 expect(await getPackageVersion(config, 'dep-c')).toEqual('1.0.0');111 expect(await getPackageVersion(config, 'dep-d')).toEqual('2.0.0');112 expect(await getPackageVersion(config, 'dep-e')).toEqual('2.0.0');113 expect(await getPackageVersion(config, 'dep-c/dep-d')).toEqual('1.0.0');114 expect(await getPackageVersion(config, 'dep-c/dep-e')).toEqual('1.0.0');115 });116});117test.concurrent('install should dedupe dependencies avoiding conflicts 7', (): Promise<void> => {118 // A@1 -> C@1 -> D@1 -> E@1119 // B@1 -> C@1 -> D@1 -> E@1120 // C@2121 // D@2122 // E@2123 // should become124 // A@1 -> C@1125 // -> D@1126 // -> E@1127 // B@1 -> C@1128 // -> D@1129 // -> E@1130 // C@2131 // D@2132 // E@2133 return runInstall({}, 'install-should-dedupe-avoiding-conflicts-7', async config => {134 expect(await getPackageVersion(config, 'dep-a')).toEqual('1.0.0');135 expect(await getPackageVersion(config, 'dep-b')).toEqual('1.0.0');136 expect(await getPackageVersion(config, 'dep-c')).toEqual('2.0.0');137 expect(await getPackageVersion(config, 'dep-d')).toEqual('2.0.0');138 expect(await getPackageVersion(config, 'dep-e')).toEqual('2.0.0');139 expect(await getPackageVersion(config, 'dep-a/dep-c')).toEqual('1.0.0');140 expect(await getPackageVersion(config, 'dep-a/dep-d')).toEqual('1.0.0');141 expect(await getPackageVersion(config, 'dep-a/dep-e')).toEqual('1.0.0');142 expect(await getPackageVersion(config, 'dep-b/dep-c')).toEqual('1.0.0');143 expect(await getPackageVersion(config, 'dep-b/dep-d')).toEqual('1.0.0');144 expect(await getPackageVersion(config, 'dep-b/dep-e')).toEqual('1.0.0');145 });146});147if (!process.env.TRAVIS || process.env.TRAVIS_OS_NAME !== 'osx') {148 // This test is unstable and timeouts on Travis OSX builds https://travis-ci.org/yarnpkg/yarn/jobs/188864079149 test.concurrent('install should dedupe dependencies avoiding conflicts 8', (): Promise<void> => {150 // revealed in https://github.com/yarnpkg/yarn/issues/112151 // adapted for https://github.com/yarnpkg/yarn/issues/1158152 return runInstall({}, 'install-should-dedupe-avoiding-conflicts-8', async config => {153 expect(await getPackageVersion(config, 'glob')).toEqual('5.0.15');154 expect(await getPackageVersion(config, 'findup-sync/glob')).toEqual('4.3.5');155 expect(await getPackageVersion(config, 'inquirer')).toEqual('0.8.5');156 expect(await getPackageVersion(config, 'lodash')).toEqual('3.10.1');157 expect(await getPackageVersion(config, 'ast-query/lodash')).toEqual('4.15.0');158 expect(await getPackageVersion(config, 'run-async')).toEqual('0.1.0');159 });160 });161}162test.concurrent('install should dedupe dependencies avoiding conflicts 9', (): Promise<void> => {163 // revealed in https://github.com/yarnpkg/yarn/issues/112164 // adapted for https://github.com/yarnpkg/yarn/issues/1158165 return runInstall({}, 'install-should-dedupe-avoiding-conflicts-9', async config => {166 expect(await getPackageVersion(config, 'glob')).toEqual('5.0.15');167 expect(await getPackageVersion(config, 'findup-sync/glob')).toEqual('4.3.5');168 expect(await getPackageVersion(config, 'inquirer')).toEqual('0.8.5');169 expect(await getPackageVersion(config, 'lodash')).toEqual('3.10.1');170 expect(await getPackageVersion(config, 'ast-query/lodash')).toEqual('4.15.0');171 expect(await getPackageVersion(config, 'run-async')).toEqual('0.1.0');172 });173});174describe('hardlink', () => {175 test.concurrent('install should hardlink repeated dependencies', (): Promise<void> => {176 // A@1177 // B@1 -> A@2178 // C@1 -> A@2 (this is hardlink to B@1->A@2)179 return runInstall({linkDuplicates: true}, 'hardlink-repeated-dependencies', async config => {180 const b_a = await fs.stat(getPackageManifestPath(config, 'b/a'));181 const c_a = await fs.stat(getPackageManifestPath(config, 'c/a'));182 expect(b_a.ino).toEqual(c_a.ino);183 });184 });185 test.concurrent('install should not hardlink repeated dependencies if linkDuplicates=false', (): Promise<void> => {...
resolutions.js
Source:resolutions.js
...8const path = require('path');9const semver = require('semver');10test.concurrent('install with simple exact resolutions should override all versions', (): Promise<void> => {11 return runInstall({}, {source: 'resolutions', cwd: 'simple-exact'}, async config => {12 expect(await getPackageVersion(config, 'a')).toEqual('1.0.0');13 expect(await getPackageVersion(config, 'b')).toEqual('1.0.0');14 expect(await getPackageVersion(config, 'd1')).toEqual('2.0.0');15 expect(await getPackageVersion(config, 'd2')).toEqual('1.0.0');16 expect(await isPackagePresent(config, 'a/d1')).toEqual(false);17 expect(await isPackagePresent(config, 'a/d2')).toEqual(false);18 expect(await isPackagePresent(config, 'b/d1')).toEqual(false);19 expect(await isPackagePresent(config, 'b/d2')).toEqual(false);20 });21});22test.concurrent('install with subtree exact resolutions should override subtree versions', (): Promise<void> => {23 return runInstall({}, {source: 'resolutions', cwd: 'subtree-exact'}, async config => {24 expect(await getPackageVersion(config, 'left-pad')).toEqual('1.0.0');25 expect(await getPackageVersion(config, 'd2')).toEqual('1.0.0');26 expect(await getPackageVersion(config, 'd2/left-pad')).toEqual('1.1.1');27 expect(await getPackageVersion(config, 'c')).toEqual('1.0.0');28 expect(await getPackageVersion(config, 'c/left-pad')).toEqual('1.1.2');29 });30});31test.concurrent('install with --frozen-lockfile with resolutions', async (): Promise<void> => {32 const reporter = new ConsoleReporter({});33 try {34 await runInstall({frozenLockfile: true}, {source: 'resolutions', cwd: 'frozen-lockfile'}, async config => {35 expect(await getPackageVersion(config, 'left-pad')).toEqual('1.1.3');36 });37 } catch (err) {38 expect(err.message).not.toContain(reporter.lang('frozenLockfileError'));39 }40});41test.concurrent('install with resolutions on optional dependencies should not resolve', (): Promise<void> => {42 return runInstall({ignoreOptional: true}, {source: 'resolutions', cwd: 'optional-deps'}, async config => {43 expect(await isPackagePresent(config, 'left-pad')).toEqual(false);44 });45});46test.concurrent('install with exotic resolutions should override versions', (): Promise<void> => {47 return runInstall({}, {source: 'resolutions', cwd: 'exotic-version'}, async config => {48 expect(await getPackageVersion(config, 'left-pad')).toEqual('1.1.1');49 });50});51test.concurrent('install with range resolutions should override versions', (): Promise<void> => {52 return runInstall({}, {source: 'resolutions', cwd: 'simple-range'}, async config => {53 expect(await getPackageVersion(config, 'left-pad')).toEqual('1.1.1');54 });55});56test.concurrent('should warn when resolution entries are incorrrect or incompatible', async (): Promise<void> => {57 let error;58 try {59 await runInstall({}, {source: 'resolutions', cwd: 'invalid-entries'});60 } catch (e) {61 error = e.message;62 }63 expect(error).toContain('Resolution field "left-pad@1.0.0" is incompatible with requested version "left-pad@~1.1.0');64 expect(error).toContain('Resolution field "wrongversion" has an invalid version entry and may be ignored');65 expect(error).toContain('Resolution field "invalidname/" does not end with a valid package name and will be ignored');66});67test.concurrent('install with resolutions should correctly install simple scoped packages', (): Promise<void> => {68 return runInstall({}, {source: 'resolutions', cwd: 'scoped-simple'}, async config => {69 expect(await getPackageVersion(config, '@scoped/a')).toEqual('1.0.0');70 expect(await getPackageVersion(config, '@scoped/b')).toEqual('2.0.0');71 });72});73test.concurrent('install with resolutions should correctly install toplevel scoped packages', (): Promise<void> => {74 return runInstall({}, {source: 'resolutions', cwd: 'scoped-toplevel'}, async config => {75 expect(await getPackageVersion(config, '@scoped/a')).toEqual('1.0.0');76 expect(await getPackageVersion(config, '@scoped/b')).toEqual('2.0.0');77 });78});79test.concurrent('install with nested resolutions', (): Promise<void> => {80 return runInstall({}, 'install-nested-resolutions', async config => {81 expect(await getPackageVersion(config, 'strip-ansi')).toEqual('2.0.1');82 expect(await getPackageVersion(config, 'ansi-regex')).toEqual('1.1.1');83 });84});85test.concurrent('install with nested resolutions using flat mode', (): Promise<void> => {86 return runInstall({flat: true}, 'install-nested-resolutions', async config => {87 expect(await getPackageVersion(config, 'strip-ansi')).toEqual('2.0.1');88 expect(await getPackageVersion(config, 'ansi-regex')).toEqual('1.1.1');89 });90});91test.concurrent('install with resolution settings should correctly bailout during the integrity check', (): Promise<92 void,93> => {94 return runInstall(95 {},96 {source: 'resolutions', cwd: 'install-with-resolution-should-bailout-during-the-integrity-check'},97 async (config, reporter): Promise<void> => {98 // remove file99 await fs.unlink(path.join(config.cwd, 'node_modules', 'left-pad', 'index.js'));100 // run install again101 const reinstall = new Install({}, config, reporter, await Lockfile.fromDirectory(config.cwd));102 await reinstall.init();103 // don't expect file being recreated because install should have bailed out104 expect(await fs.exists(path.join(config.cwd, 'node_modules', 'left-pad', 'index.js'))).toBe(false);105 },106 );107});108test.concurrent('adding resolutions after install should cause lockfile regeneration on second install', (): Promise<109 void,110> => {111 return runInstall(112 {},113 {source: 'resolutions', cwd: 'adding-resolutions-should-cause-lockfile-regeneration'},114 async (config, reporter): Promise<void> => {115 const packageJson = await fs.readFile(path.join(config.cwd, 'package.json'));116 // create new package.json with resolutions which override e/left-pad version117 const newPackageJson = JSON.parse(packageJson);118 newPackageJson.resolutions = {};119 newPackageJson.resolutions['e/left-pad'] = '1.1.1';120 // write new package.json121 await fs.writeFile(path.join(config.cwd, 'package.json'), JSON.stringify(newPackageJson));122 // expect left-pad in e/node_modules to be present and have corrent version123 // since it is not satisfied by top-level dependency124 expect(semver.satisfies(await getPackageVersion(config, 'e/left-pad'), '^1.0.0')).toBe(true);125 // run install again126 const reinstall = new Install({}, config, reporter, await Lockfile.fromDirectory(config.cwd));127 await reinstall.init();128 // don't expect left-pad in e/node_modules since it's now being replaced by single dependency left-pad@1.1.1129 expect(await isPackagePresent(config, 'e/left-pad')).toBe(false);130 const lockfile = await Lockfile.fromDirectory(config.cwd);131 const lockManifest = lockfile.getLocked('left-pad@^1.0.0');132 // check that new version of e/left-pad in lockfile is correctly updated133 expect(lockManifest && lockManifest.version).toEqual('1.1.1');134 },135 );...
is-greater-version.test.js
Source:is-greater-version.test.js
1jest.mock('../util/get-package-version');2const isGreaterVersion = require('../is-greater-version');3const getPackageVersion = require('../util/get-package-version');4describe('npm-is-greater-version', () => {5 beforeEach(() => {6 jest.clearAllMocks();7 });8 it('handles greater', async () => {9 // The first call will be for old, the second will be for new.10 getPackageVersion.mockReturnValueOnce('1.2.2').mockReturnValueOnce('1.2.3');11 // Setup the octokit, setup the context.12 const mockOctokit = {};13 const mockContext = {14 eventName: 'push',15 payload: require('../../../__tests__/mock-push-payload.json'),16 sha: '38f97e063d849701fd0bef158ebf4f3001edefd7',17 ref: '',18 workflow: '',19 action: '',20 actor: '',21 job: '',22 runNumber: -1,23 runId: -1,24 };25 const actual = await isGreaterVersion(mockOctokit, mockContext);26 expect(actual).toBeTruthy();27 expect(getPackageVersion.mock.calls.length).toBe(2);28 // Call 1.29 expect(getPackageVersion.mock.calls[0][1]).toBe('userName');30 expect(getPackageVersion.mock.calls[0][2]).toBe('package-release-test');31 expect(getPackageVersion.mock.calls[0][3]).toBe(32 'e311b74c1e615ccef73cfe8d708c40b7480ce549'33 );34 // Call 2.35 expect(getPackageVersion.mock.calls[1][1]).toBe('userName');36 expect(getPackageVersion.mock.calls[1][2]).toBe('package-release-test');37 expect(getPackageVersion.mock.calls[1][3]).toBe(38 '38f97e063d849701fd0bef158ebf4f3001edefd7'39 );40 });41 it('handles less than', async () => {42 // The first call will be for old, the second will be for new.43 getPackageVersion.mockReturnValueOnce('2.2.2').mockReturnValueOnce('1.2.3');44 // Setup the octokit, setup the context.45 const mockOctokit = {};46 const mockContext = {47 eventName: 'push',48 payload: require('../../../__tests__/mock-push-payload.json'),49 sha: '38f97e063d849701fd0bef158ebf4f3001edefd7',50 ref: '',51 workflow: '',52 action: '',53 actor: '',54 job: '',55 runNumber: -1,56 runId: -1,57 };58 const actual = await isGreaterVersion(mockOctokit, mockContext);59 expect(actual).not.toBeTruthy();60 expect(getPackageVersion.mock.calls.length).toBe(2);61 // Call 1.62 expect(getPackageVersion.mock.calls[0][1]).toBe('userName');63 expect(getPackageVersion.mock.calls[0][2]).toBe('package-release-test');64 expect(getPackageVersion.mock.calls[0][3]).toBe(65 'e311b74c1e615ccef73cfe8d708c40b7480ce549'66 );67 // Call 2.68 expect(getPackageVersion.mock.calls[1][1]).toBe('userName');69 expect(getPackageVersion.mock.calls[1][2]).toBe('package-release-test');70 expect(getPackageVersion.mock.calls[1][3]).toBe(71 '38f97e063d849701fd0bef158ebf4f3001edefd7'72 );73 });74 it('handles equals', async () => {75 // The first call will be for old, the second will be for new.76 getPackageVersion.mockReturnValueOnce('2.2.2').mockReturnValueOnce('2.2.2');77 // Setup the octokit, setup the context.78 const mockOctokit = {};79 const mockContext = {80 eventName: 'push',81 payload: require('../../../__tests__/mock-push-payload.json'),82 sha: '38f97e063d849701fd0bef158ebf4f3001edefd7',83 ref: '',84 workflow: '',85 action: '',86 actor: '',87 job: '',88 runNumber: -1,89 runId: -1,90 };91 const actual = await isGreaterVersion(mockOctokit, mockContext);92 expect(actual).not.toBeTruthy();93 expect(getPackageVersion.mock.calls.length).toBe(2);94 // Call 1.95 expect(getPackageVersion.mock.calls[0][1]).toBe('userName');96 expect(getPackageVersion.mock.calls[0][2]).toBe('package-release-test');97 expect(getPackageVersion.mock.calls[0][3]).toBe(98 'e311b74c1e615ccef73cfe8d708c40b7480ce549'99 );100 // Call 2.101 expect(getPackageVersion.mock.calls[1][1]).toBe('userName');102 expect(getPackageVersion.mock.calls[1][2]).toBe('package-release-test');103 expect(getPackageVersion.mock.calls[1][3]).toBe(104 '38f97e063d849701fd0bef158ebf4f3001edefd7'105 );106 });107 it('handles exception', async () => {108 // The first call will be for old, the second will be for new.109 getPackageVersion.mockImplementation(() => {110 throw new Error('Error Occurred');111 });112 // Setup the octokit, setup the context.113 const mockOctokit = {};114 const mockContext = {115 eventName: 'push',116 payload: require('../../../__tests__/mock-push-payload.json'),117 sha: '38f97e063d849701fd0bef158ebf4f3001edefd7',118 ref: '',119 workflow: '',120 action: '',121 actor: '',122 job: '',123 runNumber: -1,124 runId: -1,125 };126 await expect(127 isGreaterVersion(mockOctokit, mockContext)128 ).rejects.toThrowError('Error Occurred');129 // Note: only one call will happen before it throws.130 expect(getPackageVersion.mock.calls.length).toBe(1);131 expect(getPackageVersion.mock.calls[0][1]).toBe('userName');132 expect(getPackageVersion.mock.calls[0][2]).toBe('package-release-test');133 expect(getPackageVersion.mock.calls[0][3]).toBe(134 'e311b74c1e615ccef73cfe8d708c40b7480ce549'135 );136 });...
test.js
Source:test.js
...25 })26 afterEach(() => nock.cleanAll())27 test('Expect to get three versions', async () => {28 expect.assertions(1)29 const { mainRegVers: result } = await getPackageVersion('bluebird')30 expect(result).toEqual(expect.arrayContaining(['1.0.0', '2.0.0', '3.0.0']))31 testRegMock.isDone()32 })33 test('Expect to get one version from regex', async () => {34 expect.assertions(1)35 const { mainRegVers: result } = await getPackageVersion('bluebird', '1.0.0')36 expect(result).toEqual(expect.arrayContaining(['1.0.0']))37 testRegMock.isDone()38 })39 test('Expect to get one versions from single digit', async () => {40 expect.assertions(1)41 const { mainRegVers: result } = await getPackageVersion('bluebird', '1')42 expect(result).toEqual(expect.arrayContaining(['1.0.0']))43 testRegMock.isDone()44 })45 test('Expect to get one versions from range 1.0.0 - 2.0.0', async () => {46 expect.assertions(1)47 const { mainRegVers: result } = await getPackageVersion('bluebird', '1.0.0 - 2.0.0')48 expect(result).toEqual(expect.arrayContaining(['1.0.0']))49 testRegMock.isDone()50 })51 test('Expect to get one versions from range 1.0.0 - 2.0.0', async () => {52 expect.assertions(1)53 const { mainRegVers: result } = await getPackageVersion('bluebird', '1.0.x - 2.0.0')54 expect(result).toEqual(expect.arrayContaining(['1.0.0']))55 testRegMock.isDone()56 })57 test('Expect to get three versions from range 1.x.x - 3.x.x', async () => {58 expect.assertions(1)59 const { mainRegVers: result } = await getPackageVersion('bluebird', '1.x.x - 3.x.x')60 expect(result.length).toBe(3)61 testRegMock.isDone()62 })63 test('Expect to get three versions from range 1 - 3', async () => {64 expect.assertions(1)65 const { mainRegVers: result } = await getPackageVersion('bluebird', '1 - 3')66 expect(result.length).toBe(3)67 testRegMock.isDone()68 })69 test('Expect to get 3,1,2,2 versions in both', async () => {70 expect.assertions(4)71 const { mainRegVers, inBoth, mainOnly, altOnly } =72 await getPackageVersion('bluebird', '1 - 5', altRegistry)73 expect(mainRegVers).toEqual(expect.arrayContaining(['1.0.0', '2.0.0', '3.0.0']))74 expect(inBoth).toEqual(expect.arrayContaining(['3.0.0']))75 expect(mainOnly).toEqual(expect.arrayContaining(['1.0.0', '2.0.0']))76 expect(altOnly).toEqual(expect.arrayContaining(['4.0.0', '5.0.0']))77 altRegMock.isDone()78 })...
integration-hoisting.js
Source:integration-hoisting.js
...5 // a -> b -> b-26 // -> c7 // -> b-28 return runInstall({}, 'install-should-prioritise-popular-transitive', async config => {9 expect(await getPackageVersion(config, 'b')).toEqual('2.0.0');10 expect(await getPackageVersion(config, 'a/b')).toEqual('0.0.0');11 });12});13test.concurrent('install hoister should prioritise popular deep dependencies', (): Promise<void> => {14 // Arrange (fixture):15 // /foo16 // /baz-117 // /hello18 // /foobar-119 // /world20 // /bar21 // /baz-122 // /hello23 // /foobar-124 // /world25 // /alice26 // /bob27 // /foobar-228 // /baz-229 // /hello30 // /foobar-131 // /world32 // Act: install33 // Assert: package version picked are foobar-2 and baz-134 return runInstall({}, 'install-should-prioritise-popular-deep', async config => {35 expect(await getPackageVersion(config, 'bob/foobar')).toEqual('2.0.0');36 expect(await getPackageVersion(config, 'foobar')).toEqual('1.0.0');37 expect(await getPackageVersion(config, 'baz')).toEqual('1.0.0');38 expect(await getPackageVersion(config, 'alice/baz')).toEqual('2.0.0');39 });40});41test.concurrent(42 'install hoister should not install prioritised popular transitive devDependencies in --prod mode',43 (): Promise<void> => {44 return runInstall({production: true}, 'install-prod-prioritized-popular-transitive-dev-dep', async config => {45 expect(await isPackagePresent(config, 'a')).toEqual(false);46 expect(await isPackagePresent(config, 'b')).toEqual(false);47 });48 },...
get-package-version-test.js
Source:get-package-version-test.js
...5describe(getPackageVersion, function() {6 it('throws if no packages', function() {7 let packageJson = {};8 expect(() => {9 getPackageVersion(packageJson, 'test-package-name');10 }).to.throw('Ember CLI blueprint version could not be determined');11 });12 it('throws if no package', function() {13 let packageJson = {14 devDependencies: {}15 };16 expect(() => {17 getPackageVersion(packageJson, 'test-package-name');18 }).to.throw('Ember CLI blueprint version could not be determined');19 });20 it('gets version as dependency', function() {21 let packageJson = {22 dependencies: {23 'test-package-name': '2.11'24 }25 };26 expect(getPackageVersion(packageJson, 'test-package-name')).to.equal('2.11');27 });28 it('gets version as devDependency', function() {29 let packageJson = {30 devDependencies: {31 'test-package-name': '2.11'32 }33 };34 expect(getPackageVersion(packageJson, 'test-package-name')).to.equal('2.11');35 });36 it('doesn\'t throw if empty string', function() {37 let packageJson = {38 dependencies: {39 'test-package-name': ''40 }41 };42 expect(getPackageVersion(packageJson, 'test-package-name')).to.equal('');43 });...
getVersions.js
Source:getVersions.js
1const getPackageVersion = require('./getPackageVersion')2async function getLatestVersions(local) {3 const res = await getPackageVersion('webpack-page-cli', 'latest')4 if (res.statusCode === 200) {5 const versions = res.body.version6 return versions7 }8 return local9}10module.exports = async function getVersions() {11 /* eslint-disable-next-line */12 const local = require('../../package.json').version13 const latest = await getLatestVersions(local)14 return {15 current: local,16 latest17 }...
version.js
Source:version.js
1'use strict';2var packageJson = require('../package.json');3function getPackageVersion() {4 return packageJson.version;5}6function getApiVersion() {7 var pattern = /([0-9])(?:\.)/g;8 return pattern.exec(getPackageVersion())[1];9}10module.exports.getPackageVersion = getPackageVersion;...
Using AI Code Generation
1const { AppiumServiceBuilder } = require('appium');2const appiumService = new AppiumServiceBuilder()3 .usingPort(4723)4 .withAppiumJS(() => {5 return require('appium');6 })7 .getPackageVersion();8console.log(appiumService);9const { AppiumServiceBuilder } = require('appium');10const appiumService = new AppiumServiceBuilder()11 .usingPort(4723)12 .withAppiumJS(() => {13 return require('appium');14 })15 .getPackageVersion();16console.log(appiumService);17const { AppiumServiceBuilder } = require('appium');18const appiumService = new AppiumServiceBuilder()19 .usingPort(4723)20 .withAppiumJS(() => {21 return require('appium');22 })23 .getPackageVersion();24console.log(appiumService);25const { AppiumServiceBuilder } = require('appium');26const appiumService = new AppiumServiceBuilder()27 .usingPort(4723)28 .withAppiumJS(() => {29 return require('appium');30 })31 .getPackageVersion();32console.log(appiumService);33const { AppiumServiceBuilder } = require('appium');34const appiumService = new AppiumServiceBuilder()35 .usingPort(4723)36 .withAppiumJS(() => {37 return require('appium');38 })39 .getPackageVersion();40console.log(appiumService);41const { AppiumServiceBuilder } = require('appium');42const appiumService = new AppiumServiceBuilder()43 .usingPort(4723)
Using AI Code Generation
1var AppiumServiceBuilder = require('appium').AppiumServiceBuilder;2var builder = new AppiumServiceBuilder();3var version = builder.getPackageVersion();4console.log(version);5var AppiumServiceBuilder = require('appium').AppiumServiceBuilder;6var builder = new AppiumServiceBuilder();7var version = builder.getLatestVersion();8console.log(version);9builder.build();10var AppiumServiceBuilder = require('appium').AppiumServiceBuilder;11var builder = new AppiumServiceBuilder();12builder.build();13console.log("Appium server is running");14builder.start();15var AppiumServiceBuilder = require('appium').AppiumServiceBuilder;16var builder = new AppiumServiceBuilder();17builder.start();18console.log("Appium server is running");19builder.startAppium();20var AppiumServiceBuilder = require('appium').AppiumServiceBuilder;21var builder = new AppiumServiceBuilder();22builder.startAppium();23console.log("Appium server is running");
Using AI Code Generation
1var appium = require("appium");2var version = appium.getPackageVersion("com.android.settings");3console.log(version);4var appium = require("appium");5var version = appium.getPackageVersion("com.android.settings");6console.log(version);7var appium = require("appium");8var version = appium.getPackageVersion("com.android.settings");9console.log(version);10var appium = require("appium");11var version = appium.getPackageVersion("com.android.settings");12console.log(version);13var appium = require("appium");14var version = appium.getPackageVersion("com.android.settings");15console.log(version);16var appium = require("appium");17var version = appium.getPackageVersion("com.android.settings");18console.log(version);19var appium = require("appium");20var version = appium.getPackageVersion("com.android.settings");21console.log(version);22var appium = require("appium");23var version = appium.getPackageVersion("com.android.settings");24console.log(version);25var appium = require("appium");26var version = appium.getPackageVersion("com.android.settings");27console.log(version);28var appium = require("appium");29var version = appium.getPackageVersion("com.android.settings");30console.log(version);31var appium = require("appium");32var version = appium.getPackageVersion("com.android.settings");33console.log(version);34var appium = require("appium");
Using AI Code Generation
1var appiumDriver = new AppiumDriver();2var version = appiumDriver.getPackageVersion('com.android.vending');3console.log(version);4var androidDriver = new AndroidDriver();5var version = androidDriver.getPackageVersion('com.android.vending');6console.log(version);7var androidDriver = new AndroidDriver();8var version = androidDriver.getPackageVersion('com.android.vending');9console.log(version);10var androidDriver = new AndroidDriver();11var version = androidDriver.getPackageVersion('com.android.vending');12console.log(version);13var androidDriver = new AndroidDriver();14var version = androidDriver.getPackageVersion('com.android.vending');15console.log(version);16var androidDriver = new AndroidDriver();17var version = androidDriver.getPackageVersion('com.android.vending');18console.log(version);19var androidDriver = new AndroidDriver();20var version = androidDriver.getPackageVersion('com.android.vending');21console.log(version);22var androidDriver = new AndroidDriver();23var version = androidDriver.getPackageVersion('com.android.vending');24console.log(version);25var androidDriver = new AndroidDriver();26var version = androidDriver.getPackageVersion('com.android.vending');27console.log(version);28var androidDriver = new AndroidDriver();29var version = androidDriver.getPackageVersion('com.android.vending');30console.log(version);31var androidDriver = new AndroidDriver();32var version = androidDriver.getPackageVersion('com.android.vending');33console.log(version);34var androidDriver = new AndroidDriver();
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!