Skip to content

Commit

Permalink
test jest
Browse files Browse the repository at this point in the history
  • Loading branch information
wtto00 committed May 10, 2024
1 parent d1ec4b1 commit e6e720e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 35 deletions.
4 changes: 3 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
67 changes: 33 additions & 34 deletions spec/afterStart.test.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down

0 comments on commit e6e720e

Please sign in to comment.