Skip to content

Commit a778e00

Browse files
committed
test: add another test to run them concurrently
1 parent 2bd1ffc commit a778e00

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const {DocumentClient} = require('aws-sdk/clients/dynamodb');
2+
3+
const ddb = new DocumentClient({
4+
convertEmptyValues: true,
5+
endpoint: 'localhost:8000',
6+
sslEnabled: false,
7+
region: 'local-env'
8+
});
9+
10+
it('should insert item into another table concurrently', async () => {
11+
await ddb.put({TableName: 'users', Item: {id: '1', hello: 'world'}}).promise();
12+
13+
const {Item} = await ddb.get({TableName: 'users', Key: {id: '1'}}).promise();
14+
15+
expect(Item).toEqual({
16+
id: '1',
17+
hello: 'world'
18+
});
19+
});

jest-dynamodb-config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ module.exports = {
55
KeySchema: [{AttributeName: 'id', KeyType: 'HASH'}],
66
AttributeDefinitions: [{AttributeName: 'id', AttributeType: 'S'}],
77
ProvisionedThroughput: {ReadCapacityUnits: 1, WriteCapacityUnits: 1}
8+
},
9+
{
10+
TableName: `users`,
11+
KeySchema: [{AttributeName: 'id', KeyType: 'HASH'}],
12+
AttributeDefinitions: [{AttributeName: 'id', AttributeType: 'S'}],
13+
ProvisionedThroughput: {ReadCapacityUnits: 1, WriteCapacityUnits: 1}
814
}
915
],
1016
port: 8000,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"coverage": "jest --coverage",
2727
"lint": "eslint . --ext .js,.ts,.json --fix",
2828
"lint:ci": "eslint . --ext .js,.ts,.json",
29-
"test": "export ENVIRONMENT=local && jest . --runInBand"
29+
"test": "export ENVIRONMENT=local && jest ."
3030
},
3131
"husky": {
3232
"hooks": {

setup.js

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

44-
if(!global.__DYNAMODB__) {
44+
if (!global.__DYNAMODB__) {
4545
global.__DYNAMODB__ = await DynamoDbLocal.launch(port, null, options);
4646
}
4747
}

0 commit comments

Comments
 (0)