Skip to content

Commit

Permalink
fix(amplify-dynamodb-simulator):callback revoked within time-limit (#…
Browse files Browse the repository at this point in the history
…7843)

* fix(amplify-dynamodb-simulator):callback revoked within time-limit

* fix(amplify-dynamodb-simulator):merged all beforeEach()/afterEach() into one

* try...catch added to clean up
  • Loading branch information
studpeps authored Oct 22, 2021
1 parent d37886f commit 7c9bb7e
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions packages/amplify-dynamodb-simulator/__test__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,26 @@ describe('emulator operations', () => {

const ensureNoDbPath = () => {
if (fs.existsSync(dbPath)) {
fs.removeSync(dbPath);
try {
fs.removeSync(dbPath);
}
catch(err) {
console.log(err);
}
}
};

beforeEach(ensureNoDbPath);
afterEach(ensureNoDbPath);

let emulators;
beforeEach(() => {
beforeEach(async () => {
ensureNoDbPath();
emulators = [];
jest.setTimeout(40 * 1000);
});
afterEach(async () => await Promise.all(emulators.map(emu => emu.terminate())));

afterEach(async () => {
await Promise.all(emulators.map(emu => emu.terminate()));
ensureNoDbPath();
});

it('should support in memory operations', async () => {
const emu = await ddbSimulator.launch();
Expand All @@ -73,15 +80,14 @@ describe('emulator operations', () => {
})
.promise();
await emuOne.terminate();

emulators = [];
const emuTwo = await ddbSimulator.launch({ dbPath });
emulators.push(emuTwo);
const dynamoTwo = await ddbSimulator.getClient(emuTwo);
const t = await dynamoTwo.listTables().promise();
expect(t).toEqual({
TableNames: ['foo'],
});
emuTwo.terminate();
});

it('should start on specific port', async () => {
Expand Down

0 comments on commit 7c9bb7e

Please sign in to comment.