Redwood: Delete current Service generated test.js templates

Created on 16 Jun 2020  路  6Comments  路  Source: redwoodjs/redwood

@RobertBroersma from our conversation last week, we discussed that the current test.js templates for Services aren't helpful and should be removed for now, correct?

https://github.com/redwoodjs/redwood/blob/master/packages/cli/src/commands/generate/service/templates/test.ts.template

Then the plan is to revisit when API side is test tooling is ready, correct?

All 6 comments

Correct!

Yeah we just included this to have something in there and remind you that you should be testing everything. But we had no idea how to actually test services at the time. 馃槵

Ok, so it felt worth it to remove the service file for now given that it won't even be a helpful foundation for people to build on.

But just removing the testFile object from service.js throws 30 failing tests. Which, if I turn them all off now, will have to be re-added when we update the test template.

I vote to keep things as is. What say you all?

Yeah I mean ideally we could just put something in there that actually exercises Prisma to make sure it's at least hooked up...my original plan was to just stick a simple db.user.findMany() and check that the result was an array, even if it was an empty array鈥攖his would be an end-to-end test that the client libs are generated and its connecting to the DB properly an no errors are raised. But at the time I was thinking about doing that we were miles away from Jest working so I had no way to check if it would work or not! And then I forgot about it until just now. 馃槄

Sorry, RC, I didn't give you all the context here -- the magical mock service worker (MSW) implementation that Robert and Peter are working on _will_ enable us to test the API! So it's in progress and came up during a conversation about testing last week. We were auditing the files/generators, which is what kicked off this topic.

tl;dr:
There's a better way to test this coming in the future!

Ok, I'm closing this out. Leaving as it for now in hopes of a better test template in the (near) future! (No pressure, Robert...)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tmeasday picture tmeasday  路  4Comments

freddydumont picture freddydumont  路  3Comments

thedavidprice picture thedavidprice  路  3Comments

slavakurilyak picture slavakurilyak  路  4Comments

wispyco picture wispyco  路  3Comments