How to use uninstallPackage method in devicefarmer-stf

Best JavaScript code snippet using devicefarmer-stf

uninstallPackage.spec.js

Source:uninstallPackage.spec.js Github

copy

Full Screen

...12var events = require('../../../lib/events');13var InvalidPackageError = require('../../../lib/errors').InvalidPackageError;14chai.use(chaiAsPromised);15chai.use(sinonChai);16describe('api.uninstallPackage()', function() {17 var uninstallPackage;18 var MockApi;19 var mockApi;20 var mockNpmCommands;21 before(function() {22 MockApi = mockApiFactory();23 mockApi = new MockApi('/project');24 mockNpmCommands = mockNpmCommandsFactory();25 uninstallPackage = rewire('../../../lib/api/uninstallPackage');26 uninstallPackage.__set__('npmCommands', mockNpmCommands);27 uninstallPackage = uninstallPackage.bind(mockApi);28 });29 var unmockFiles = null;30 afterEach(function() {31 if (unmockFiles) {32 unmockFiles();33 unmockFiles = null;34 }35 MockApi.reset();36 mockApi.reset();37 mockNpmCommands.reset();38 });39 it('should throw an error if no package is specified', function() {40 var pkg = {};41 var config = {};42 var files = {43 '/project/package.json': JSON.stringify(pkg),44 '/project/.skivvyrc': JSON.stringify(config)45 };46 unmockFiles = mockFiles(files);47 var expected, actual;48 expected = InvalidPackageError;49 actual = [50 uninstallPackage({}),51 uninstallPackage({ package: undefined }),52 uninstallPackage({ package: null }),53 uninstallPackage({ package: false }),54 uninstallPackage({ package: '' })55 ];56 return Promise.all(actual.map(function(actual) {57 return expect(actual).to.be.rejectedWith(expected);58 }));59 });60 it('should throw an error if the specified package does not exist', function() {61 var pkg = {};62 var config = {};63 var files = {64 '/project/package.json': JSON.stringify(pkg),65 '/project/.skivvyrc': JSON.stringify(config)66 };67 unmockFiles = mockFiles(files);68 var expected, actual;69 expected = InvalidPackageError;70 actual = uninstallPackage({71 package: 'nonexistent'72 });73 return expect(actual).to.be.rejectedWith(expected);74 });75 it('should run npm uninstall [package] in the specified directory', function() {76 var pkg = {};77 var config = {};78 var files = {79 '/project/package.json': JSON.stringify(pkg),80 '/project/.skivvyrc': JSON.stringify(config),81 '/project/node_modules/@skivvy/skivvy-package-goodbye-world/package.json': '{}',82 '/project/node_modules/@skivvy/skivvy-package-goodbye-world/index.js': 'exports.tasks = {};'83 };84 unmockFiles = mockFiles(files);85 var options = {86 package: 'goodbye-world'87 };88 var expected, actual;89 return uninstallPackage(options)90 .then(function(returnValue) {91 expected = undefined;92 actual = returnValue;93 expect(actual).to.equal(expected);94 var npmOptions = {95 'save-dev': true96 };97 expect(mockNpmCommands.uninstall).to.have.been.calledWith('@skivvy/skivvy-package-goodbye-world', npmOptions, '/project');98 });99 });100 it('should remove the package namespace from the config file', function() {101 var pkg = {};102 var config = {103 packages: {104 '@package/hello-world': {105 message: 'Hello, world!'106 },107 'goodbye-world': {108 message: 'Goodbye, world!'109 }110 }111 };112 var files = {113 '/project/package.json': JSON.stringify(pkg),114 '/project/.skivvyrc': JSON.stringify(config),115 '/project/node_modules/@package/skivvy-package-hello-world/package.json': '{}',116 '/project/node_modules/@package/skivvy-package-hello-world/index.js': 'exports.tasks = {};',117 '/project/node_modules/@skivvy/skivvy-package-goodbye-world/package.json': '{}',118 '/project/node_modules/@skivvy/skivvy-package-goodbye-world/index.js': 'exports.tasks = {};'119 };120 unmockFiles = mockFiles(files);121 var options = {122 package: 'goodbye-world'123 };124 var expected, actual;125 return uninstallPackage(options)126 .then(function(returnValue) {127 actual = JSON.parse(fs.readFileSync('/project/.skivvyrc', 'utf8'));128 expected = {129 packages: {130 '@package/hello-world': {131 message: 'Hello, world!'132 }133 }134 };135 expect(actual).to.eql(expected);136 });137 });138 it('should handle scoped packages correctly', function() {139 var pkg = {};140 var config = {141 packages: {142 'hello-world': {143 message: 'Hello, world!'144 },145 '@package/goodbye-world': {146 message: 'Goodbye, world!'147 }148 }149 };150 var files = {151 '/project/package.json': JSON.stringify(pkg),152 '/project/.skivvyrc': JSON.stringify(config),153 '/project/node_modules/@package/skivvy-package-goodbye-world/package.json': '{}',154 '/project/node_modules/@package/skivvy-package-goodbye-world/index.js': 'exports.tasks = {};',155 '/project/node_modules/@skivvy/skivvy-package-hello-world/package.json': '{}',156 '/project/node_modules/@skivvy/skivvy-package-hello-world/index.js': 'exports.tasks = {};'157 };158 unmockFiles = mockFiles(files);159 var options = {160 package: '@package/goodbye-world'161 };162 var expected, actual;163 return uninstallPackage(options)164 .then(function(returnValue) {165 expected = undefined;166 actual = returnValue;167 expect(actual).to.equal(expected);168 var npmOptions = {169 'save-dev': true170 };171 expect(mockNpmCommands.uninstall).to.have.been.calledWith('@package/skivvy-package-goodbye-world', npmOptions, '/project');172 actual = JSON.parse(fs.readFileSync('/project/.skivvyrc', 'utf8'));173 expected = {174 packages: {175 'hello-world': {176 message: 'Hello, world!'177 }178 }179 };180 expect(actual).to.eql(expected);181 });182 });183 it('should not modify the config file if the namespace does not exist', function() {184 var pkg = {};185 var config = {186 packages: {187 '@my-packages/hello-world': {188 message: 'Hello, world!'189 }190 }191 };192 var files = {193 '/project/package.json': JSON.stringify(pkg),194 '/project/.skivvyrc': JSON.stringify(config),195 '/project/node_modules/@my-packages/skivvy-package-hello-world/package.json': '{ "name": "@my-packages/skivvy-package-hello-world", "version": "1.2.3" }',196 '/project/node_modules/@my-packages/skivvy-package-hello-world/index.js': 'exports.tasks = {}; exports.description = \'Hello World package\';',197 '/project/node_modules/@skivvy/skivvy-package-goodbye-world/package.json': '{ "name": "skivvy-package-goodbye-world", "version": "1.2.3" }',198 '/project/node_modules/@skivvy/skivvy-package-goodbye-world/index.js': 'exports.tasks = {}; exports.description = \'Goodbye World package\';'199 };200 unmockFiles = mockFiles(files);201 var options = {202 package: 'goodbye-world'203 };204 var expected, actual;205 return uninstallPackage(options)206 .then(function(returnValue) {207 actual = JSON.parse(fs.readFileSync('/project/.skivvyrc', 'utf8'));208 expected = {209 packages: {210 '@my-packages/hello-world': {211 message: 'Hello, world!'212 }213 }214 };215 expect(actual).to.eql(expected);216 });217 });218 it('should not modify the config file if no namespaces exist', function() {219 var pkg = {};220 var config = {};221 var files = {222 '/project/package.json': JSON.stringify(pkg),223 '/project/.skivvyrc': JSON.stringify(config),224 '/project/node_modules/@skivvy/skivvy-package-goodbye-world/package.json': '{ "name": "skivvy-package-goodbye-world", "version": "1.2.3" }',225 '/project/node_modules/@skivvy/skivvy-package-goodbye-world/index.js': 'exports.tasks = {}; exports.description = \'Goodbye World package\';'226 };227 unmockFiles = mockFiles(files);228 var options = {229 package: 'goodbye-world'230 };231 var expected, actual;232 return uninstallPackage(options)233 .then(function(returnValue) {234 actual = JSON.parse(fs.readFileSync('/project/.skivvyrc', 'utf8'));235 expected = {};236 expect(actual).to.eql(expected);237 });238 });239 it('should have tests for events', function() {240 var pkg = {};241 var config = {};242 var files = {243 '/project/package.json': JSON.stringify(pkg),244 '/project/.skivvyrc': JSON.stringify(config),245 '/project/node_modules/@skivvy/skivvy-package-goodbye-world/package.json': '{ "name": "skivvy-package-goodbye-world", "version": "1.2.3" }',246 '/project/node_modules/@skivvy/skivvy-package-goodbye-world/index.js': 'exports.tasks = {}; exports.description = \'Goodbye World package\';'247 };248 unmockFiles = mockFiles(files);249 var expected, actual;250 expected = [251 {252 event: events.UNINSTALL_PACKAGE_STARTED,253 package: 'goodbye-world',254 path: '/project'255 },256 {257 event: events.UNINSTALL_PACKAGE_COMPLETED,258 package: 'goodbye-world',259 path: '/project'260 }261 ];262 actual = [];263 mockApi.on(events.UNINSTALL_PACKAGE_STARTED, onStarted);264 mockApi.on(events.UNINSTALL_PACKAGE_COMPLETED, onCompleted);265 mockApi.on(events.UNINSTALL_PACKAGE_FAILED, onFailed);266 function onStarted(data) {267 actual.push({268 event: events.UNINSTALL_PACKAGE_STARTED,269 package: data.package,270 path: data.path271 });272 }273 function onCompleted(data) {274 actual.push({275 event: events.UNINSTALL_PACKAGE_COMPLETED,276 package: data.package,277 path: data.path278 });279 }280 function onFailed(data) {281 actual.push({282 event: events.UNINSTALL_PACKAGE_FAILED,283 error: data.error,284 package: data.package,285 path: data.path286 });287 }288 return uninstallPackage({289 package: 'goodbye-world'290 })291 .then(function() {292 return expect(actual).to.eql(expected);293 });294 });...

Full Screen

Full Screen

installDeps.ts

Source:installDeps.ts Github

copy

Full Screen

...147 await addRegistryToArgs(command, args, cliRegistry);148 args.push(packageName);149 await executeCommand(command, args, targetDir);150}151async function uninstallPackage(152 targetDir: string,153 command: string,154 cliRegistry: string,155 packageName: string,156) {157 checkPackageManagerIsSupported(command);158 // @ts-ignore159 const args = packageManagerConfig[command].uninstallPackage;160 await addRegistryToArgs(command, args, cliRegistry);161 args.push(packageName);162 await executeCommand(command, args, targetDir);163}164async function updatePackage(165 targetDir: string,...

Full Screen

Full Screen

Package.spec.js

Source:Package.spec.js Github

copy

Full Screen

...12 it('loadPackages', () => {13 assert.deepEqual(PackageActions.loadPackages(), {type: 'LOAD_PACKAGES'})14 })15 it('uninstallPackage', () => {16 assert.deepEqual(PackageActions.uninstallPackage('foo'), {17 type: 'UNINSTALL_PACKAGE', payload: {name: 'foo'},18 })19 })20 })21 describe('reducer', () => {22 it('returns the initial state', () => {23 const r = reducer(undefined, {})24 assert.deepEqual(r, [])25 })26 it('handles RECEIVE_PACKAGES', () => {27 const packages = ['foo', 'bar']28 const r = reducer(['old', 'packages'], {type: 'RECEIVE_PACKAGES', payload: {packages}})29 assert.deepEqual(r, packages)30 })31 it('handles the default case', () => {32 const packages = ['old', 'packages']33 const r = reducer(packages, {type: 'SOME_OTHER_ACTION'})34 assert.deepEqual(r, packages)35 })36 })37 describe('state', () => {38 it('loadPackages', async () => {39 const result = await collectState({40 reducer,41 action: PackageActions.loadPackages(),42 count: 2,43 })44 assert(result.length === 2)45 assert.deepEqual(result[0], {46 action: PackageActions.loadPackages(),47 result: {},48 })49 assert.deepEqual(result[1], {50 action: PackageActions.receivePackages(mock.packages),51 result: mock.packages,52 })53 })54 it('uninstallPackage', async () => {55 const result = await collectState({56 reducer: rootReducer,57 action: PackageActions.uninstallPackage('foo'),58 count: 2,59 })60 assert(result.length === 2)61 assert.deepEqual(result[0], {62 action: PackageActions.uninstallPackage('foo'),63 result: {64 app: {},65 packages: [],66 },67 })68 const devStatus = {69 text: 'Not really uninstalling in DEVELOPMENT.',70 type: 'success',71 }72 assert.deepEqual(result[1], {73 action: AppActions.setStatus(devStatus),74 result: {75 app: {76 status: devStatus,77 },78 packages: [],79 },80 })81 })82 })83 describe('sagas', () => {84 it('loadPackages', () => {85 const gen = PackageSagas.loadPackages()86 assert.deepEqual(gen.next().value, call(pacman.getPackages))87 assert.deepEqual(88 gen.next(mock.packages).value,89 put(PackageActions.receivePackages(mock.packages))90 )91 assert.deepEqual(gen.next(), {done: true, value: undefined})92 })93 it('uninstallPackage', () => {94 const name = 'package name'95 const status = mock.status;96 const gen = PackageSagas.uninstallPackage({payload: {name}})97 assert.deepEqual(gen.next().value, call(pacman.uninstallPackage, name))98 assert.deepEqual(gen.next(status).value, put(AppActions.setStatus(status)))99 assert.deepEqual(gen.next(), {done: true, value: undefined})100 })101 })...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var uninstallPackage = require('devicefarmer-stf').uninstallPackage;2uninstallPackage('com.android.chrome', function (err) {3 if (err) {4 console.log(err);5 } else {6 console.log('Package uninstalled successfully');7 }8});

Full Screen

Using AI Code Generation

copy

Full Screen

1var uninstallPackage = require('devicefarmer-stf').uninstallPackage;2uninstallPackage('com.android.chrome', function (err) {3 if (err) {4 console.log('Error:', err);5 } else {6 console.log('Success');7 }8});9var installPackage = require('devicefarmer-stf').installPackage;10installPackage('C:\\Users\\saurabh\\Downloads\\chrome.apk', function (err) {11 if (err) {12 console.log('Error:', err);13 } else {14 console.log('Success');15 }16});17var getPackageInfo = require('devicefarmer-stf').getPackageInfo;18getPackageInfo('com.android.chrome', function (err, data) {19 if (err) {20 console.log('Error:', err);21 } else {22 console.log('Success', data);23 }24});25var getDeviceList = require('devicefarmer-stf').getDeviceList;26getDeviceList(function (err, data) {27 if (err) {28 console.log('Error:', err);29 } else {30 console.log('Success', data);31 }32});33var getDeviceStatus = require('devicefarmer-stf').getDeviceStatus;34getDeviceStatus('emulator-5554', function (err, data) {35 if (err) {36 console.log('Error:', err);37 } else {38 console.log('Success', data);39 }40});41var getDeviceDetails = require('devicefarmer-stf').getDeviceDetails;42getDeviceDetails('emulator-5554', function (err, data) {43 if (err) {44 console.log('Error:', err);45 } else {46 console.log('Success', data);47 }48});

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf');2var device = new stf.Device();3device.uninstallPackage('com.android.chrome');4var stf = require('devicefarmer-stf');5var device = new stf.Device();6device.uninstallPackage('com.android.chrome');7var stf = require('devicefarmer-stf');8var device = new stf.Device();9device.installPackage('C:\\Users\\Downloads\\chrome.apk');10var stf = require('devicefarmer-stf');11var device = new stf.Device();12device.installPackage('C:\\Users\\Downloads\\chrome.apk');13var stf = require('devicefarmer-stf');14var device = new stf.Device();15device.startApp('com.android.chrome');16var stf = require('devicefarmer-stf');17var device = new stf.Device();18device.startApp('com.android.chrome');19var stf = require('devicefarmer-stf');20var device = new stf.Device();21device.stopApp('com.android.chrome');22var stf = require('devicefarmer-stf');23var device = new stf.Device();24device.stopApp('com.android.chrome');25var stf = require('devicefarmer-stf');26var device = new stf.Device();27device.getDeviceDetails();28var stf = require('devicefarmer-stf');29var device = new stf.Device();30device.getDeviceDetails();31var stf = require('devicefarmer-stf');32var device = new stf.Device();33device.getDeviceDetails();34var stf = require('devicefarmer-stf');

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf-client');2 if (err) {3 console.log('Error connecting to STF');4 console.log(err);5 return;6 }7 console.log('Connected to STF');8 client.getDevices(function(err, devices) {9 if (err) {10 console.log('Error getting devices');11 console.log(err);12 return;13 }14 console.log('Got devices');15 console.log(devices);16 var device = devices[0];17 client.uninstallPackage(device.serial, 'com.example.test', function(err) {18 if (err) {19 console.log('Error uninstalling package');20 console.log(err);21 return;22 }23 console.log('Package uninstalled');24 });25 });26});27{ [Error: socket hang up] code: 'ECONNRESET' }28{ [Error: socket hang up] code: 'ECONNRESET' }29{ [Error: socket hang up] code: 'ECONNRESET' }

Full Screen

Using AI Code Generation

copy

Full Screen

1var uninstallPackage = require('devicefarmer-stf').uninstallPackage;2var options = {3};4uninstallPackage(options, function(err, data) {5 if (err) {6 console.log(err);7 } else {8 console.log(data);9 }10});

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf-api');2client.uninstallPackage('com.android.chrome', function(err, data) {3 if (err) {4 console.log('Error in uninstalling package');5 console.log(err);6 } else {7 console.log('Package uninstalled successfully');8 console.log(data);9 }10});11{ success: true }12uninstallApplication (applicationName, callback)13var stf = require('devicefarmer-stf-api');14client.uninstallApplication('Chrome', function(err, data) {15 if (err) {16 console.log('Error in uninstalling application');17 console.log(err);18 } else {19 console.log('Application uninstalled successfully');20 console.log(data);21 }22});23{ success: true }24getDeviceInfo (callback)25var stf = require('devicefarmer-stf-api');26client.getDeviceInfo(function(err, data) {27 if (err) {28 console.log('Error in getting device information');29 console.log(err);30 } else {31 console.log('Device information');32 console.log(data);33 }34});35{ abi: 'armeabi-v7a',36 { fps: 59.999996185302734,

Full Screen

Using AI Code Generation

copy

Full Screen

1var uninstallPackage = require('devicefarmer-stf').uninstallPackage;2uninstallPackage('com.example.test',function(err, result){3 if(err){4 console.log('Error: '+err);5 }else{6 console.log('Result: '+result);7 }8});9var startApp = require('devicefarmer-stf').startApp;10startApp('com.example.test',function(err, result){11 if(err){12 console.log('Error: '+err);13 }else{14 console.log('Result: '+result);15 }16});17var stopApp = require('devicefarmer-stf').stopApp;18stopApp('com.example.test',function(err, result){19 if(err){20 console.log('Error: '+err);21 }else{22 console.log('Result: '+result);23 }24});25var isAppInstalled = require('devicefarmer-stf').isAppInstalled;26isAppInstalled('com.example.test',function(err, result){27 if(err){28 console.log('Error: '+err);29 }else{30 console.log('Result: '+result);31 }32});33var isAppRunning = require('devicefarmer-stf').isAppRunning;

Full Screen

Using AI Code Generation

copy

Full Screen

1var stfClient = require('devicefarmer-stf-client');2var device = new stfClient.Device(client, '7B5D7A0B');3device.uninstallPackage('com.android.chrome')4 .then(function() {5 console.log("Package uninstalled");6 })7 .catch(function(err) {8 console.log("Error uninstalling package: " + err);9 });10var stfClient = require('devicefarmer-stf-client');11var device = new stfClient.Device(client, '7B5D7A0B');12 .then(function() {13 console.log("Package installed");14 })15 .catch(function(err) {16 console.log("Error installing package: " + err);17 });18var stfClient = require('devicefarmer-stf-client');19var device = new stfClient.Device(client, '7B5D7A0B');20 .then(function() {21 console.log("Package installed");22 })23 .catch(function(err) {24 console.log("Error installing package: " + err);25 });26var stfClient = require('devicefarmer-stf-client');27var device = new stfClient.Device(client, '7B5D7A0B');28device.setOrientation('portrait')29 .then(function() {30 console.log("Orientation set");31 })32 .catch(function(err) {33 console.log("Error setting orientation: " + err);34 });35var stfClient = require('devicefarmer-stf-client');

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run devicefarmer-stf 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