Skip to content

Commit

Permalink
feat(core): Remove deprecated recordIfExpired option (#295)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `recordIfExpired` is no longer supported, please use `expiryStrategy` instead.
  • Loading branch information
offirgolan authored Jan 13, 2020
1 parent 4e3163f commit 5fe991d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 51 deletions.
17 changes: 0 additions & 17 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,6 @@ polly.configure({
});
```

## recordIfExpired

_deprecated! use [expiryStrategy](#expiryStrategy)_
_Type_: `Boolean`
_Default_: `false`

If a request's recording has expired, pass-through to the server and
record a new response.

**Example**

```js
polly.configure({
recordIfExpired: true
});
```

## recordFailedRequests

_Type_: `Boolean`
Expand Down
25 changes: 1 addition & 24 deletions packages/@pollyjs/core/src/utils/merge-configs.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@
import mergeWith from 'lodash-es/mergeWith';
import { EXPIRY_STRATEGIES } from '@pollyjs/utils';

function deprecateRecordIfExpired(mergedConfig) {
if (mergedConfig.hasOwnProperty('recordIfExpired')) {
console.warn(
'[Polly] config option "recordIfExpired" is deprecated. Please use "expiryStrategy".'
);

if (mergedConfig.recordIfExpired) {
// replace recordIfExpired: true with expiryStrategy: record
mergedConfig.expiryStrategy = EXPIRY_STRATEGIES.RECORD;
} else {
// replace recordIfExpired: false with expiryStrategy: warn
mergedConfig.expiryStrategy = EXPIRY_STRATEGIES.WARN;
}

delete mergedConfig.recordIfExpired;
}

return mergedConfig;
}

function customizer(objValue, srcValue, key) {
// Arrays and `context` options should just replace the existing value
Expand All @@ -30,7 +9,5 @@ function customizer(objValue, srcValue, key) {
}

export default function mergeConfigs(...configs) {
const mergedConfig = mergeWith({}, ...configs, customizer);

return deprecateRecordIfExpired(mergedConfig);
return mergeWith({}, ...configs, customizer);
}
10 changes: 0 additions & 10 deletions tests/integration/adapter-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,6 @@ export default function adapterTests() {
await this.polly.persister.delete(this.polly.recordingId);
});

it('re-records on expired recording if recordIfExpired is true', async function() {
this.polly.configure({ recordIfExpired: true });
expect(await testExpiration.call(this)).to.equal(true);
});

it('replays the expired recording if recordIfExpired is false', async function() {
this.polly.configure({ recordIfExpired: false });
expect(await testExpiration.call(this)).to.equal(false);
});

it('warns and plays back on expired recording if expiryStrategy is "warn"', async function() {
this.polly.configure({ expiryStrategy: 'warn' });
expect(await testExpiration.call(this)).to.equal(false);
Expand Down

0 comments on commit 5fe991d

Please sign in to comment.