Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
jest-dynalite
Advanced tools
Enchaned unit testing, with a mock DynamoDB instance
jest-dynalite
is a fork of @shelf/jest-dynamodb, and allows unit tests to execute real
queries against a local DynamoDB instance.
Using this library makes writing quiries with dynamodb very easy, and your tests can really check if your data is manipulated in the way you expect it to be. This in turn makes your tests much more robust.
jest-dynalite
was created in an attempt to address some of the most important missing
features of @shelf/jest-dynamodb
yarn add jest-dynalite -D
In your package root, create a jest-dynalite-config.json
with the tables schemas,
and an optional basePort
to run dynalite on:
{
"tables": [
{
"TableName": "table",
"KeySchema": [{ "AttributeName": "id", "KeyType": "HASH" }],
"AttributeDefinitions": [{ "AttributeName": "id", "AttributeType": "S" }],
"ProvisionedThroughput": {
"ReadCapacityUnits": 1,
"WriteCapacityUnits": 1
}
}
],
"basePort": 8000
}
const client = new DocumentClient({
...yourConfig,
...(process.env.MOCK_DYNAMODB_ENDPOINT && {
endpoint: process.env.MOCK_DYNAMODB_ENDPOINT,
sslEnabled: false,
region: "local"
})
});
process.env.MOCK_DYNAMODB_ENDPOINT
is unqiue to each test runner.
jest.config.js
module.exports = {
...
preset: "jest-dynalite"
}
The simple preset config will use the config and clear tables between tests by default.
This the recommended usage, unless you have custom setupFilesAfterEnv
or testEnvironment
set.
setup.js
import "jest-dynalite/dist/setupTables";
// Optional (but recommended)
import "jest-dynalite/dist/clearAfterEach";
jest.config.js
module.exports = {
...
testEnvironment: "jest-dynalite/dist/environment",
setupFilesAfterEnv: ["./setup.js"]
}
This setup should be used if you want to override the default config of clearAfterEach
.
Specify the config dir
setupBeforeEnv.js
import { setup } from "jest-dynalite";
// You must give it a config directory
setup(__dirname);
setupAfterEnv.js
import { startDb, stopDb, createTables, deleteTables } from "jest-dynalite";
beforeAll(startDb);
// Create tables but don't delete them after tests
beforeAll(createTables);
// or
beforeEach(createTables);
afterEach(deleteTables);
afterAll(stopDb);
jest.config.js
module.exports = {
...
setupFiles: ["./setupBeforeEnv.js"],
setupFilesAfterEnv: ["./setupAfterEnv.js"]
}
This is by far the most complicated setup, but provides the ability to specifiy
an environment other than jest-dynalite
, and also allows you to specify a config directory.
MIT
FAQs
Run your tests using Jest & Dynalite
The npm package jest-dynalite receives a total of 42,316 weekly downloads. As such, jest-dynalite popularity was classified as popular.
We found that jest-dynalite demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.