[@pollyjs/core] expiryStrategy option (#37254)

* [@pollyjs/core] expiryStrategy option

* unit test

* spacing
This commit is contained in:
BoruiGu 2019-07-31 13:05:47 -04:00 committed by Jesse Trinity
parent f41a05471c
commit 2696df1a3a
2 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,7 @@
// Type definitions for @pollyjs/core 2.3
// Type definitions for @pollyjs/core 2.6
// Project: https://github.com/netflix/pollyjs/tree/master/packages/@pollyjs/core
// Definitions by: feinoujc <https://github.com/feinoujc>
// Borui Gu <https://github.com/BoruiGu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
@ -29,8 +30,10 @@ export interface PollyConfig {
logging?: boolean;
recordIfMissing?: boolean;
/** @deprecated use expiryStrategy */
recordIfExpired?: boolean;
recordFailedRequests?: boolean;
expiryStrategy?: 'warn' | 'error' | 'record';
expiresIn?: string | null;
timing?: ((ms: number) => Promise<void>) | (() => Promise<void>);

View File

@ -5,7 +5,8 @@ const polly = new Polly('test recording', {
mode: MODES.PASSTHROUGH,
recordFailedRequests: true,
adapters: ['xhr', 'fetch'],
persister: 'rest',
persister: 'rest',
expiryStrategy: 'error',
timing: Timing.relative(3),
matchRequestsBy: {
method: true,