Defender store mock when running locally

Hey, is there any official way to mock the Defender kvstore when running locally?

Thanks.

Not yet. What would work best for you…?

  • An ephemeral in-memory store
  • A disk-based local store
  • A store that connects to the kvstore in your Defender account via an API token

For testing purposes I find a disk-based local store sufficient, so you can try persistence across multiple runs, even from different autotasks.

1 Like

Got it! Will work on it this week.

Hey @abarmat, check out the 1.10.0-local.0 release of the kvstore-client. It’s still not tagged as latest until it’s reviewed, but it may help in the meantime!

const { KeyValueStoreClient } = require('defender-kvstore-client');

async function local() {
  // Creates an instance of the client that will write to a local file
  const store = new KeyValueStoreClient({ path: '/tmp/foo/store.json' });

  // The store.json file will contain { myKey: myValue }
  await store.put('myKey', 'myValue');
}
1 Like