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

Add toHaveBeenNthFetchedWith #44

Open
sigfriedCub1990 opened this issue Apr 5, 2024 · 1 comment
Open

Add toHaveBeenNthFetchedWith #44

sigfriedCub1990 opened this issue Apr 5, 2024 · 1 comment

Comments

@sigfriedCub1990
Copy link
Member

✨ Feature proposal

Add toHaveBeenNthFetchedWith.

🎯 Motivation

We would like to assert that an endpoint has been called with a given payload at a certain point in time.

👀 Example

wrap(App)
	.withNetwork([
		path: '/users/1/update/',
		requestBody: { 
			name: 'Alexander',
			surname: 'Nevsky'
		},
	])
	.mount()

await startSomeFlow()
await updateUser() // Let's suppose that in this page we update the user data
await doSomethingElse()
await updateUserAgain() // At the end we update the user again

expect('/users/1/update/').toHaveBeenNthFetchedWith(1, {
	name: 'Alexander',
	surname: 'Nevsky',
}) // We want to assert that the first time this endpoint was called, the payload was this one.

💬 Comments

We had a situation within acmofy-app that required this.

@sigfriedCub1990 sigfriedCub1990 changed the title Add toHaveBeenNthCalledWith Add toHaveBeenNthFetchedWith Apr 5, 2024
@alfupe
Copy link
Contributor

alfupe commented Apr 5, 2024

:notbad: it would be very useful sometimes… maybe the naming is what confuses me a bit more but I have no better alternative to propose so 🤐 (I thought something with "at" but it doesn't work)

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

3 participants