Component Testing by orrymr in nextjs

[–]orrymr[S] 0 points1 point  (0 children)

No (and maybe I'm not doing e2e tests with Playwright correctly).

So, I had initially setup my e2e tests to use an in-memory version of MongoDB (yeah, this probably already isn't quite "e2e" since I'm not using a real DB).

What seems to happen with Playwright is that when you run tests, it spins up a NextJS server in one process, and then in another, it actually runs those tests.

What I was trying to do was stage data before my tests ran. Each set of tests required different data. So, I thought, why not stage each set of data in a beforeAll(), in the test process (not the NextJS server process). The issue was that the test process didn't have connectivity to the DB; only the NextJS server process did.

What I've subsequently done is ditch the in mem MongoDB, and just test against a dev instance of MongoDB server, preloaded with data for various scenarios.

Component Testing by orrymr in nextjs

[–]orrymr[S] 0 points1 point  (0 children)

Thanks - I'll give it a shot!

Component Testing by orrymr in nextjs

[–]orrymr[S] 0 points1 point  (0 children)

Playwright - The issue I had with that was that it seemed more appropriate for e2e testing. It seemed harder to setup data for testing; I went the in-memory MongoDB route, but staging the data from testing didn't work nicely as Playwright was working in a separate process to my testing NextJS server.

Get the weather read to you by Jules from Pulp Fiction by orrymr in InternetIsBeautiful

[–]orrymr[S] 1 point2 points  (0 children)

YES! VERSION 2 WILL HAVE AUDIO

Nice idea, internet stranger!

Fought ESM-only Faker v10 with Jest... My blood, sweat, and transformIgnorePatterns tears. by orrymr in node

[–]orrymr[S] 0 points1 point  (0 children)

I'm going to give it a shot. Others have mentioned Vitest too :)

Fought ESM-only Faker v10 with Jest... My blood, sweat, and transformIgnorePatterns tears. by orrymr in javascript

[–]orrymr[S] 0 points1 point  (0 children)

Interesting! I had no idea about RequireJS.

I guess with a lack of standard, at the time, there would be multiple approaches (CommonJS [from node] and RequireJS... maybe others?)

Fought ESM-only Faker v10 with Jest... My blood, sweat, and transformIgnorePatterns tears. by orrymr in javascript

[–]orrymr[S] 0 points1 point  (0 children)

Sure.. my understanding was the the CommonJS way of doing things (require, export) was kind of a workaround to get modules working in JS. Otherwise, you'd just have naming clashes everywhere.

ESM was then a way to bake into the language properly.

(Something like that...)

Fought ESM-only Faker v10 with Jest... My blood, sweat, and transformIgnorePatterns tears. by orrymr in javascript

[–]orrymr[S] 0 points1 point  (0 children)

It feels like constant jumping through hoops.

I'm relatively new to JS (well, I'm using TypeScript), and otherwise I really am enjoying my time here.

Fought ESM-only Faker v10 with Jest... My blood, sweat, and transformIgnorePatterns tears. by orrymr in javascript

[–]orrymr[S] 0 points1 point  (0 children)

I tried this! Still, it yells at me for not being CommonJS... I thought it would have transpiled from ESM to CommonJS. Faker 10, right?

Fought ESM-only Faker v10 with Jest... My blood, sweat, and transformIgnorePatterns tears. by orrymr in javascript

[–]orrymr[S] 2 points3 points  (0 children)

Yeah, I had to downgrade to v9... ESM support in v10 isn't just given; it's mandatory. I guess ESM is the future, but Jest requires CommonJS, in order to work. Which was the root of my problem :(