Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nerdwallet/jest-nock-fixtures

Package Overview
Dependencies
Maintainers
7
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nerdwallet/jest-nock-fixtures - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

.github/workflows/ci.yml

4

CHANGELOG.md

@@ -0,1 +1,5 @@

## 2.1.0 (2022-12-08)
- Move many logs behind a `JEST_NOCK_FIXTURES_VERBOSE` environment variable flag
## 2.0.0 (2021-03-31) benjroy

@@ -2,0 +6,0 @@

13

package.json
{
"version": "2.0.0",
"version": "2.1.0",
"name": "@nerdwallet/jest-nock-fixtures",

@@ -9,9 +9,8 @@ "description": "jest-nock-fixtures",

"jest": "jest --config=jest.config.js --coverage",
"build": "true",
"fix-lint": "npm run lint -- --fix",
"format": "yarn lint --fix",
"lint": "eslint src --ext .js",
"test": "npm run jest --",
"test:wild": "JEST_NOCK_FIXTURES_MODE=wild npm run test --",
"test:record": "JEST_NOCK_FIXTURES_MODE=record npm run test --",
"test:lockdown": "JEST_NOCK_FIXTURES_MODE=lockdown npm run test --"
"test": "yarn jest --",
"test:wild": "JEST_NOCK_FIXTURES_MODE=wild yarn test",
"test:record": "JEST_NOCK_FIXTURES_MODE=record yarn test",
"test:lockdown": "JEST_NOCK_FIXTURES_MODE=lockdown yarn test"
},

@@ -18,0 +17,0 @@ "repository": {

@@ -10,3 +10,3 @@ # jest-nock-fixtures

## Setup
## Setup and usage

@@ -62,3 +62,3 @@ Configure `jest` to setup this wrapper before the tests in each test file are executed. In `jest@24`, this can be achieved by configuring `setupFilesAfterEnv` (https://jestjs.io/docs/en/configuration#setupfilesafterenv-array)

#### Modes
### Modes

@@ -100,2 +100,10 @@ Available modes:

### Log levels
By default, minimal logs will be printed. To increase the verbosity of the logs, set `JEST_NOCK_FIXTURES_VERBOSE` when running tests. For example:
```sh
JEST_NOCK_FIXTURES_VERBOSE=1 npm run test
```
## Developing

@@ -105,6 +113,15 @@

- `npm run test`: Run unit tests and generate coverage reports
- `yarn install`: Install all dependencies
- `yarn test`: Run unit tests and generate coverage reports
Other commands you might care about:
- `npm run lint`: Run lint
- `yarn lint`: Run lint
- `yarn format`: Automatically fix code issues
### Releasing a new version
1. Update the version in `package.json`. Take care to follow semantic versioning.
2. Update `CHANGELOG.md` to reflect the changes in the new version.
3. Push both of the above changes to the `master` branch.
4. Create a new release in the GitHub CI. GitHub Actions will automatically publish the new version to npm.

@@ -90,5 +90,10 @@ const { dirname, basename, join } = require('path');

].join(' ');
// utility for logging user messages
// eslint-disable-next-line no-console
const print = str => console.log(message(str));
const log = str => console.log(message(str));
const logVerbose = str => {
if (!process.env.JEST_NOCK_FIXTURES_VERBOSE) return;
log(str);
};

@@ -110,3 +115,3 @@ // ensure a valid mode is being used

if (mode === MODES.WILD) {
print("Not intercepting any requests in 'wild' mode");
log("Not intercepting any requests in 'wild' mode");
return;

@@ -135,7 +140,7 @@ }

fixture = JSON.parse(readFileSync(fixtureFilepath()));
print(yellow(`loaded nock fixture file: ${fixtureFilepath()}`));
logVerbose(yellow(`loaded nock fixture file: ${fixtureFilepath()}`));
} catch (err) {
fixture = {};
if (err.code !== 'ENOENT') {
print(
log(
red(

@@ -194,3 +199,3 @@ `Error parsing fixture file:\nFile:\n\t${fixtureFilepath()}\nError message:\n\t${

nock.define(recordings);
print(
logVerbose(
yellow(

@@ -206,3 +211,3 @@ `Defined (${

if (unmatched.length) {
print(yellow(`${unmatched.length} unmatched requests`));
log(yellow(`${unmatched.length} unmatched requests`));
}

@@ -220,3 +225,3 @@ },

nock.define(recordings);
print(
logVerbose(
yellow(

@@ -257,3 +262,3 @@ `Defined (${

// message what happened
print(yellow(`Recorded ${recordings.length} request(s)`));
logVerbose(yellow(`Recorded ${recordings.length} request(s)`));
} else if (has(fixture, uniqueTestName())) {

@@ -270,3 +275,3 @@ delete fixture[uniqueTestName()];

delete fixture[name];
print(yellow(`Removed obsolete fixture entry for ${name}`));
logVerbose(yellow(`Removed obsolete fixture entry for ${name}`));
});

@@ -291,3 +296,3 @@

// message what happened
print(
logVerbose(
yellow(`Wrote recordings to fixture file: ${fixtureFilepath()}`)

@@ -302,3 +307,3 @@ );

// cleanup obsolete nock fixture file and dir if they exist
print(yellow(`Nothing recorded, removing ${fixtureFilepath()}`));
logVerbose(yellow(`Nothing recorded, removing ${fixtureFilepath()}`));
// remove the fixture file

@@ -310,3 +315,3 @@ unlinkSync(fixtureFilepath());

// message what happened
print(
logVerbose(
yellow(

@@ -313,0 +318,0 @@ `Removed ${fixtureDir()} directory because no fixtures were left.`

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc