@nerdwallet/jest-nock-fixtures
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -0,1 +1,6 @@ | ||
## 1.1.0 (2020-10-09) brian123zx | ||
- When nocks encounters a number of unmatched requests, the error function it calls now includes the path it expects to find the nock file at. | ||
- Fixes a bug introduced in v1.0.2 where the first argument to `unmatchedErrorMessage` was the length of the unmatched request array instead of the array itself | ||
## 1.0.2 (2020-10-07) brian123zx | ||
@@ -2,0 +7,0 @@ |
{ | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"name": "@nerdwallet/jest-nock-fixtures", | ||
@@ -4,0 +4,0 @@ "description": "jest-nock-fixtures", |
@@ -34,6 +34,6 @@ # jest-nock-fixtures | ||
createJestNockFixturesTestWrapper({ | ||
unmatchedErrorMessage: reqs => | ||
unmatchedErrorMessage: (reqs, { fixtureFilepath }) => | ||
`unmatched requests not allowed (found ${ | ||
reqs.length | ||
}).\n\nRun \`npm run test:record\` to update fixtures, and try again.` | ||
}).\n\nRun \`npm run test:record\` to update fixtures, and try again.` | ||
}); | ||
@@ -40,0 +40,0 @@ ``` |
@@ -31,4 +31,6 @@ const { dirname, basename, join } = require('path'); | ||
}, | ||
unmatchedErrorMessage = unmatchedRequests => | ||
`unmatched requests not allowed (found ${unmatchedRequests}). Record fixtures and try again.`, | ||
unmatchedErrorMessage = (unmatchedRequests, { fixtureFilepath }) => | ||
`unmatched requests not allowed (found ${ | ||
unmatchedRequests.length | ||
}). Looking for fixtures at ${fixtureFilepath}. Record fixtures and try again.`, | ||
} = options; | ||
@@ -116,3 +118,3 @@ | ||
const unmatchedLength = unmatched.length; | ||
const cachedUnmatched = unmatched; | ||
@@ -126,10 +128,14 @@ // full cleanup | ||
// report about unmatched requests | ||
if (unmatchedLength) { | ||
if (cachedUnmatched.length) { | ||
if (isLockdownMode()) { | ||
throw new Error( | ||
`${logNamePrefix}: ${mode}: ${unmatchedErrorMessage(unmatchedLength)}` | ||
`${logNamePrefix}: ${mode}: ${unmatchedErrorMessage(cachedUnmatched, { | ||
fixtureFilepath: fixtureFilepath(), | ||
})}` | ||
); | ||
} else if (isDryrunMode()) { | ||
console.warn( // eslint-disable-line no-console,prettier/prettier | ||
`${logNamePrefix}: ${mode}: ${unmatchedLength} unmatched requests` | ||
`${logNamePrefix}: ${mode}: ${ | ||
cachedUnmatched.length | ||
} unmatched requests` | ||
); | ||
@@ -136,0 +142,0 @@ } |
@@ -58,6 +58,6 @@ const { dirname, basename, join } = require('path'); | ||
logNamePrefix = 'jest-nock-fixtures', | ||
unmatchedErrorMessage = reqs => | ||
unmatchedErrorMessage = (reqs, { fixtureFilepath }) => | ||
`unmatched requests not allowed (found ${ | ||
reqs.length | ||
}).\n\nRun with env variable \`JEST_NOCK_FIXTURES_MODE=record\` to update fixtures.`, | ||
}). Looking for fixtures at ${fixtureFilepath}\n\nRun with env variable \`JEST_NOCK_FIXTURES_MODE=record\` to update fixtures.`, | ||
beforeAll = global.beforeAll, | ||
@@ -64,0 +64,0 @@ afterAll = global.afterAll, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27626
279