Skip to content

incompatible behaviour introduced with v13.3.2 #2500

@andreas-roessler

Description

@andreas-roessler

Please avoid duplicates

Reproducible test case

Code snipped added to "What happened?"

Nock Version

v13.3.2

Node Version

18.15.0

TypeScript Version

No response

What happened?

Hi dear nock-team,

with commit
8aab603
a new breaking change/behaviour has been introduced which crashes our tests of several projects.
It is reordering the interceptors which leads to a different sequence handling.

'use strict';

// Console with nock 13.3.2 (incorrect)
//   special file
//   all others
//   all others
//
// Console with nock 13.3.1 (correct)
//   special file
//   special file
//   all others


const https = require('https');
const nock = require('nock');
nock.back.setMode('lockdown');

const get = uri => {
	return new Promise(resolve => {
		https.get(uri, res => {
			const data = [];
			res.on('data', chunk => data.push(chunk));
			res.on('end', () => resolve(Buffer.concat(data).toString()));
		});
	});
};

(async() => {
	nock("https://test.com")
		.persist()
		.get("/special-file.json").reply(200, "special file")
		.get(/.*/).reply(200, "all others");

	console.log(await get("https://test.com/special-file.json"));
	console.log(await get("https://test.com/special-file.json"));
	console.log(await get("https://test.com/other-file.json"));
})();

Would you be interested in contributing a fix?

  • yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions