From e6e720e52fe9473edab3a1397708d2201fd11091 Mon Sep 17 00:00:00 2001 From: wtto00 Date: Fri, 10 May 2024 21:54:53 +0800 Subject: [PATCH] test jest --- jest.config.ts | 4 ++- spec/afterStart.test.ts | 67 ++++++++++++++++++++--------------------- 2 files changed, 36 insertions(+), 35 deletions(-) diff --git a/jest.config.ts b/jest.config.ts index 720d2a9..9455b92 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -12,7 +12,9 @@ const jestConfig: JestConfigWithTsJest = { '^(\\.{1,2}/.*)\\.js$': '$1' }, collectCoverage: true, - coverageDirectory: 'spec/coverage' + coverageDirectory: 'spec/coverage', + verbose: true, + maxConcurrency: 1 }; export default jestConfig; diff --git a/spec/afterStart.test.ts b/spec/afterStart.test.ts index c771b08..1c15039 100644 --- a/spec/afterStart.test.ts +++ b/spec/afterStart.test.ts @@ -1,43 +1,42 @@ import path from 'path'; import Android from '../src/index.js'; -describe('after start a emulator', () => { - const android = new Android({ debug: true }); +const android = new Android({ debug: true }); - let emulatorId = ''; - beforeAll(async () => { - const avds = await android.listAVDs(); - let avdName = ''; - if (avds.length === 0) { - avdName = `TestCreate_${Math.random().toString().substring(2)}`; - await android.createAVD({ name: avdName, apiLevel: 31, force: false }); - } else { - avdName = avds[0].Name; - } - console.log('start', new Date().toUTCString()); - const res = await android.start({ - avd: avdName, - noaudio: true, - noBootAnim: true, - noSnapshot: true, - noSnapshotSave: true, - noWindow: true, - gpu: 'swiftshader_indirect' - }); - emulatorId = res.id; - console.log('emulatorId', emulatorId, new Date().toUTCString()); - if (emulatorId) { - await android.ensureReady(emulatorId); - } else { - throw Error('no emulator'); - } - }, 1200000); +let emulatorId = ''; +beforeAll(async () => { + const avds = await android.listAVDs(); + let avdName = ''; + if (avds.length === 0) { + avdName = `TestCreate_${Math.random().toString().substring(2)}`; + await android.createAVD({ name: avdName, apiLevel: 31, force: false }); + } else { + avdName = avds[0].Name; + } + console.log('start', new Date().toUTCString()); + const res = await android.start({ + avd: avdName, + noaudio: true, + noBootAnim: true, + noSnapshot: true, + noSnapshotSave: true, + noWindow: true, + gpu: 'swiftshader_indirect' + }); + emulatorId = res.id; + if (emulatorId) { + await android.ensureReady(emulatorId); + } else { + throw Error('no emulator'); + } +}, 1200000); - afterAll(async () => { - console.log('waitForStop', new Date().toUTCString()); - await android.waitForStop(emulatorId); - }, 60000); +afterAll(async () => { + console.log('waitForStop', new Date().toUTCString()); + await android.waitForStop(emulatorId); +}, 60000); +describe('after start a emulator', () => { test('list packages', async () => { console.log('list packages', new Date().toUTCString()); if (emulatorId) {