
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
@castore/lib-test-tools
Advanced tools
Test tooling for the Castore library.
# npm
npm install --save-dev @castore/lib-test-tools
# yarn
yarn add --dev @castore/lib-test-tools
This package has @castore/core
as peer dependency, so you will have to install it as well:
# npm
npm install @castore/core
# yarn
yarn add @castore/core
The mockEventStore
util returns a copy of the provided EventStore
connected to an InMemoryEventStorageAdapter
, empty or with a given initial state. It follows the EventStore
interface but adds a reset
method to reset it to the provided initial state. The original event store is not muted.
import { EventStore } from '@castore/core';
import { mockEventStore } from '@castore/lib-test-tools';
const pokemonsEventStore = new EventStore({
...
});
const pokemonAppearCommand = new Command({
...
});
describe('My awesome test', () => {
const mockedPokemonsEventStore = mockEventStore(pokemonsEventStore, [
// 👇 Provide initial state (list of event details) in a type-safe way
{
aggregateId: '123',
version: 1,
type: 'POKEMON_APPEARED',
...
},
]);
beforeEach(() => {
// 👇 Reset to initial state
mockedPokemonsEventStore.reset();
});
it('pushes a POKEMON_APPEARED event', async () => {
const { pokemonId } = await pokemonAppearCommand.handler({
requiredEventsStores: [mockedPokemonsEventStore],
...
});
const { events } = await mockedPokemonsEventStore.getEvents(pokemonId);
expect(events).toHaveLength(1);
});
});
Unlike mockEventStore
, the muteEventStore
util mutes the original event store and replace its storage adapter with an InMemoryEventStorageAdapter
matching the provided initial state.
import { EventStore } from '@castore/core';
import { muteEventStore } from '@castore/lib-test-tools';
const pokemonsEventStore = new EventStore({
...
});
const functionUsingTheEventStore = async () => {
...
};
describe('My awesome test', () => {
muteEventStore(pokemonsEventStore, [
// 👇 Provide initial state (list of event details) in a type-safe way
{
aggregateId: '123',
version: 1,
type: 'POKEMON_APPEARED',
...
},
]);
it('does something incredible', async () => {
await functionUsingTheEventStore();
// 👇 Use the original event store
const { events } = await pokemonsEventStore.getEvents('123');
expect(events).toHaveLength(1);
});
});
FAQs
Test tooling for the Castore library.
We found that @castore/lib-test-tools demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers 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 researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.