node-tdd 4.0.2 → 4.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -91,8 +91,21 @@ export default (opts) => {
91
91
  nockBack.setMode(hasCassette ? 'lockdown' : 'record');
92
92
  nockBack.fixtures = opts.cassetteFolder;
93
93
  nockMock.patch();
94
- nockListener.subscribe('no match', () => {
94
+ nockListener.subscribe('no match', (req) => {
95
95
  assert(hasCassette === true);
96
+
97
+ // convert 404 response code to 500
98
+ const destroyOriginal = req.destroy;
99
+ req.destroy = (err) => {
100
+ if (err.status === 404 && err.statusCode === 404 && err.code === 'ERR_NOCK_NO_MATCH') {
101
+ // eslint-disable-next-line no-param-reassign
102
+ err.statusCode = 500;
103
+ // eslint-disable-next-line no-param-reassign
104
+ err.status = 500;
105
+ }
106
+ return destroyOriginal.call(req, err);
107
+ };
108
+
96
109
  const { protocol, options, body } = requestInjector.getLast();
97
110
  if (anyFlagPresent(['record'])) {
98
111
  expectedCassette.push(async () => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "node-tdd",
3
3
  "type": "module",
4
- "version": "4.0.2",
4
+ "version": "4.0.3",
5
5
  "description": "Drop in extension for mocha to abstract commonly used test setups",
6
6
  "main": "lib/index.js",
7
7
  "scripts": {