windyScripts/dev-directory

Create test utilities

Closed this issue · 2 comments

Related Issues
Depends on: #9

Description
Most of our tests will depend on users being created. Creating a full-fledged users with all the fields is cumbersome, so we can make it a bit easier by adding some test utilities for creating a random user.

To this end, we'll create a new file server/test/utils.ts, which exports a new function createUser which creates a user with randomly generated fields in all fields. The arguments should just be a subset of User fields (excluding ID, but this doesn't have to be strict since it's just used for testing), where any fields specified are used to create the user, and any unspecified fields are randomly generated using falso.

For example, the following:

await createUser({ discord_name: "poop#1234", bio: "i like poop" })

Should create a user that has their discord_name and bio to be the above values, and random values for everything else. Bonus points if there's some low percentage (like 20%) that a non-required field is blank.

Acceptance Criteria

  • The utility function exists and is used in tests instead of creating users manually

@timmyichen I want to take this but I see it depends on #9 , after reading through that issue I think I can still work on this w/o #9 being completed right?

@MainlyColors You can totally get started on it now! #9 just makes it more relevant since that's the piece that duplicates code. But feel free to pick it up :)