Files
directus/packages/sdk/tests/utils.ts
WoLfulus 3c1204b928 SDK 2.0 (#4510)
* add new sdk

* update version

* fixes and sdk documentation

* typing updates, documentation

* added missing endpoints

* targeting minified version for unpkg

* removed unused types file

* fixed non minified versions

* fix sdk exports

* fix the fix

* Remove old sdk

* Remove old sdk docs

* Install types for Jest, add npm test

* Rely on npm exclusively

* Remove examples folder

* Move typescript down

* Update sdk.md

* added auto refresh and requested changes

added more http test calls
fixed typing issue in customized types

* remove unused endpoint

* updated docs

* added singletons, fixed typing issues, added password handlers

* rename graphql function and fixed system endpoint

* Remove unused imports, fix build

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
Co-authored-by: Ben Haynes <ben@rngr.org>
2021-03-30 18:23:23 -04:00

27 lines
725 B
TypeScript

import nock, { back, BackMode } from 'nock';
export const URL = process.env.TEST_URL || 'http://localhost';
export const MODE = process.env.TEST_MODE || 'dryrun';
back.fixtures = `${__dirname}/fixtures`;
back.setMode(MODE as BackMode);
export type Test = (url: string, nock: () => nock.Scope) => Promise<void>;
export type TestSettings = {
url?: string;
fixture?: string;
};
export function test(name: string, test: Test, settings?: TestSettings) {
it(name, async () => {
if (settings?.fixture) {
await back(settings.fixture, async () => {
await test(settings?.url || URL, () => nock(settings?.url || URL));
});
} else {
await test(settings?.url || URL, () => nock(settings?.url || URL));
}
});
}