Seeking advice in using testing?

Hey, I am noob in testing actually this is my first project where I write some unit test I have a question, How do I write test for this endpoint using jest and supertest?"/create", async (req, res, next) => {
    try {
        if (Object.keys(req.body).length === 0 && req.body.constructor === Object) {
            throw new BadRequest("Missing: request body content")
        const { username, email } = req.body
        const token = jwt.sign(
                // expire in 1 hour
                exp: Math.floor( / 1000) + (60 * 60),
                data: req.body
            }, process.env.JWT_SECRET)
        const mailUser = {
            email: email,
            name: username,
            title: "Welcome to our app",
            body: `
            <h1>Please click the given link to activate your accound.</h1>
            message: "Please kindly confirm your account"
    catch (e) {

lt,dr - Here users try to register themselves to my application and here just I take their register credential’s like email,password,username and send a link after storing them in jwt token on their provided email and wait when they click on the link and register themselves or save their data into database.
I already try this -

test('should send signup email to the user.',async () => {
    await request(app)
        username: "test",
        fullName: "test user",
        email: "",
        password: "test-user"

But it only test is email successfully send email to the user or not. How do I test this endpoint?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.