
Research
/Security News
Shai Hulud Strikes Again (v2)
Another wave of Shai-Hulud campaign has hit npm with more than 500 packages and 700+ versions affected.
@scaleleap/jest-polly
Advanced tools
Integrate Jest with PollyJS for a smooth experience of HTTP recording.

Smoothest Jest integration with PollyJS.
Integrate Jest with PollyJS for a smooth HTTP recording and playback experience for your integration tests.
Can be set via POLLY_MODE environment variable.
Mode can be one of the following:
replay: Replay responses from recordings.record: Force Polly to record all requests. This will overwrite recordings that already exist.passthrough: Passes all requests through directly to the server without recording or replaying.Default: replay
Usage:
POLLY_MODE=record npm t
If a request's recording is not found, pass-through to the server and record the response.
Can be set via POLLY_RECORD_IF_MISSING environment variable.
Default: false if running in CI environment or true otherwise.
Usage:
POLLY_RECORD_IF_MISSING=true npm t
Sometimes requests and/or responses may contain secret data, such as API keys, or oAuth tokens.
To automatically sanitize the recordings, you may add a list of secrets to the config to be replaced.
See "Change PollyJS default config" section for details.
// use a Record-style config, where keys are secrets,
// and values are what they will be replaced with
jestPollyConfigService.config = {
secrets: {
'somepassword': 'x',
'my-api-key': 'x',
}
}
// or simply use an array, and everything will be replaced with `x` by default:
jestPollyConfigService.config = {
secrets: [process.env.MY_SECRET_VALYE]
}
In your package.json
{
"jest": {
"setupFilesAfterEnv": ["@scaleleap/jest-polly"]
}
}
Or in jest.config.js
module.exports = {
setupFilesAfterEnv: ['@scaleleap/jest-polly'],
};
In my.test.js
import '@scaleleap/jest-polly';
import fetch from 'node-fetch';
test('is ok', async () => {
const response = await fetch('https://httpstat.us/200');
expect(response.ok).toBe(true);
});
Use the polly instance to change default behavior.
import { jestPollyContext } from '@scaleleap/jest-polly';
import fetch from 'node-fetch';
jestPollyContext
.polly
.server
.any('https://httpstat.us/500')
.intercept((req, res) => res.sendStatus(500));
test('is not ok', async () => {
const response = await fetch('https://httpstat.us/500');
expect(response.ok).not.toBe(true);
});
If you want to change the default config, use the following setter.
Note: the config will be merged with the default config, and not overwritten.
import { jestPollyConfigService } from '@scaleleap/jest-polly';
jestPollyConfigService.config = {
matchRequestsBy: {
order: false
}
}
npm i -D @scaleleap/jest-polly
Keep it simple. Keep it minimal. Don't put every single feature just because you can.
@spotify/polly-jest-presets,
but the project wasn't well maintained@jomaxx/jest-polly, but wasn't using setup-polly-jestThis project is licensed under the MIT License
FAQs
Integrate Jest with PollyJS for a smooth experience of HTTP recording.
The npm package @scaleleap/jest-polly receives a total of 2,435 weekly downloads. As such, @scaleleap/jest-polly popularity was classified as popular.
We found that @scaleleap/jest-polly demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Another wave of Shai-Hulud campaign has hit npm with more than 500 packages and 700+ versions affected.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.