Skip to content

Commit 9959436

Browse files
authored
Merge pull request #92 from ballpointcarrot/watch-fix
Allow jest watch / watchAll
2 parents cb67d84 + c8c8036 commit 9959436

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

setup.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ module.exports = async function () {
4141
DynamoDbLocal.configureInstaller(installerConfig);
4242
}
4343

44-
global.__DYNAMODB__ = await DynamoDbLocal.launch(port, null, options);
44+
if(!global.__DYNAMODB__) {
45+
global.__DYNAMODB__ = await DynamoDbLocal.launch(port, null, options);
46+
}
4547
}
4648

4749
await createTables(dynamoDB, newTables);

teardown.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
const DynamoDbLocal = require('dynamodb-local');
22
const debug = require('debug')('jest-dynamodb');
33

4-
module.exports = async function () {
4+
module.exports = async function (jestArgs) {
55
// eslint-disable-next-line no-console
66
debug('Teardown DynamoDB');
77

88
if (global.__DYNAMODB__) {
9-
await DynamoDbLocal.stopChild(global.__DYNAMODB__);
9+
const watching = jestArgs.watch || jestArgs.watchAll;
10+
if (!watching) {
11+
await DynamoDbLocal.stopChild(global.__DYNAMODB__);
12+
}
1013
} else {
1114
const dynamoDB = global.__DYNAMODB_CLIENT__;
1215
const {TableNames: tableNames} = await dynamoDB.listTables().promise();

0 commit comments

Comments
 (0)