Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onMethod calls are no longer been matched over onAny Calls #396

Open
ymor opened this issue Sep 9, 2024 · 0 comments
Open

onMethod calls are no longer been matched over onAny Calls #396

ymor opened this issue Sep 9, 2024 · 0 comments

Comments

@ymor
Copy link

ymor commented Sep 9, 2024

Not sure if this is now somewhat expected behaviour for V2 but I had a few tests where in the before each id use an onAny, and then in the specific tests I'd override with onPost and this would previously match the more specific onPost handler. But its now ignoring the more specific handler and returning 200 from the onAny.

const MockAdapter = require('axios-mock-adapter');

const mock = new MockAdapter(axios);

describe('Example', () => {
  afterEach(() => {
    mock.reset();
  });
  beforeEach(() => {
    mock.onAny().reply(200);
  });

  test('should match on post', async () => {
    mock.onPost().reply(409); //It used to match this more specific handler pre v2
    const x = await axios.post('/anywhere', {
      validateStatus: (status) => status === 200 || status === 409,
    });
    expect(x.status).toBe(409)
  })
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant