@keyv/test-suite
TypeScript icon, indicating that this package has built-in type declarations

2.0.3 • Public • Published

@keyv/test-suite keyv

Test suite for Keyv API compliance

build codecov npm npm

Complete AVA test suite to test a Keyv storage adapter for API compliance.

Usage

Install

Install vitest, keyv and @keyv/test-suite as development dependencies.

npm install --save-dev vitest keyv @keyv/test-suite

Then update keyv and @keyv/test-suite versions to * in package.json to ensure you're always testing against the latest version.

Create Test File

test.js

import test from 'vitest';
import keyvTestSuite from '@keyv/test-suite';
import Keyv from 'keyv';
import KeyvStore from './';

const store = () => new KeyvStore();
keyvTestSuite(test, Keyv, store);

Where KeyvStore is your storage adapter.

Set your test script in package.json to vitest.

"scripts": {
  "test": "vitest"
}

Example for Storage Adapters

Take a look at keyv/redis for an example of an existing storage adapter using @keyv/test-suite.

Testing Compression Adapters

If you're testing a compression adapter, you can use the keyvCompresstionTests method instead of keyvTestSuite.

import test from 'vitest';
import { keyvCompresstionTests, KeyvGzip } from '@keyv/test-suite';
import Keyv from 'keyv';

keyvCompresstionTests(test, new KeyvGzip());

License

MIT © Jared Wray

Dependencies (6)

Dev Dependencies (4)

Package Sidebar

Install

npm i @keyv/test-suite

Weekly Downloads

103

Version

2.0.3

License

MIT

Unpacked Size

84 kB

Total Files

7

Last publish

Collaborators

  • jaredwray