Mock serverside API requests using NextJS and MSWjs

  Рет қаралды 1,969

Eddie Jaoude

Eddie Jaoude

Күн бұрын

Пікірлер: 21
@eddiejaoude
@eddiejaoude 4 ай бұрын
See MSWjs and NextJS with Instrumentation feature in a real open source project github.com/EddieHubCommunity/HealthCheck
@fransjoakimtitulaer2404
@fransjoakimtitulaer2404 3 ай бұрын
Thank you! It's been hard finding good resources covering this
@eddiejaoude
@eddiejaoude 3 ай бұрын
yes I found it difficult when researching also. Thank you for the great feedback. I have a blog version also if you need for reference
@kakseigrae
@kakseigrae 2 ай бұрын
Super helpful, thank you! For the morons like me who rush to use Next 15, you must not add the experimental object as it's no longer experimental feature and you must put the instrumentarium file in the root of your project (not ./app), where package.json lives. Cheers!
@eddiejaoude
@eddiejaoude 2 ай бұрын
Thanks for the great feedback! Ah yes, the new version doesn't require the extra config. Thanks for the reminder
@harshitpant1743
@harshitpant1743 Ай бұрын
This is super helpful @kakseigrae , I am using 15 as well. But the import {setupServer} from 'msw/node' is not working, Also 'msw/browser' does not work for me . Do you know the reason for this?
@jayraldempino1944
@jayraldempino1944 4 ай бұрын
I use mswjs in client side which sooo good. In terms of the mock data, fakerjs is also better with it. Thanks for this, man! Thumbs up for this tutorial.
@eddiejaoude
@eddiejaoude 4 ай бұрын
Thank you for the great feedback!!
@euanmorgann
@euanmorgann 20 күн бұрын
Have you managed to get this working with recent versions of msw? For me any version greater than 2.4.3 is completely broken
@eddiejaoude
@eddiejaoude 20 күн бұрын
I have not tried yet, i will try soon on my new project and latest versions.
@johnaroj
@johnaroj 7 күн бұрын
for serveractions you just mock it with /api/route and use a POST or there is another way to write functions?
@eddiejaoude
@eddiejaoude 7 күн бұрын
if you mock a function it is more of a unit test, by mocking external api calls, you are doing more of an end to end test
@dartess
@dartess 3 ай бұрын
Unfortunately this doesn't work in build time, only in dev time.
@euanmorgann
@euanmorgann 20 күн бұрын
It's not really intended for build time it's meant for tests / local dev
@eddiejaoude
@eddiejaoude 20 күн бұрын
yep 👍
@minhazulabedin9603
@minhazulabedin9603 4 ай бұрын
I always get the error: Package path ./browser is not exported from package
@eddiejaoude
@eddiejaoude 4 ай бұрын
i am not using the browserfile, i am using the node file. what are you trying to do?
@JibbaJabber
@JibbaJabber 4 ай бұрын
#Noice
@eddiejaoude
@eddiejaoude 4 ай бұрын
thank you
@negarmir3334
@negarmir3334 Ай бұрын
Hi @eddiejaoude I am using the nextjs15 with mswjs 2.6.8. I just added the instrumentation.ts in the root of app next to package.json but it is not working. Do you have any idea how to fix it?
@eddiejaoude
@eddiejaoude 20 күн бұрын
it is unclear what is not working in your project, let's start at the beginning, does your instrumentation file trigger?
Why prisma calls directly in Next is a MISTAKE
7:51
Web Dev Cody
Рет қаралды 18 М.
Mock Servers | The Exploratory
7:00
Postman
Рет қаралды 39 М.
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 120 МЛН
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
Mock out OAuth Provider using MswJS (NextJS and Next-Auth)
6:48
Mock a Basic HTTP Response - Mocking REST API with Mock Service Worker
4:08
Mock Service Worker
Рет қаралды 31 М.
This is how Winglang got 400 GitHub stars in 3 days
8:23
Nevo David
Рет қаралды 1,9 М.
Why do Developers HATE writing tests? And are they right?
21:31
Generate unit tests with EarlyAI
19:16
Eddie Jaoude
Рет қаралды 11 М.
Mock Service Worker with React
39:20
Anson the Developer
Рет қаралды 14 М.
Next.js 15 Breakdown (Everything You Need To Know)
18:10
Web Dev Simplified
Рет қаралды 95 М.
No scheduler? No Cron? No problem... use GitHub Actions
5:26
Eddie Jaoude
Рет қаралды 820
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 120 МЛН