randomKek
randomKek

Reputation: 1128

javascript mocha, node exceptional test cases

The application I am writing has sign up, after a user signs up they receive an email, the email contains an unique URL to the activation link, for example:

Welcome. Click <a href="https://api.app.com/users/{id}/activate/{token}">here</a> to activate your account.

The problem is, I use mocha to automate testing for my restful JSON application I wrote in Node.js (which is the link at the activation url).

What would be a solution for this kind of solution, I mean writing a parser for the user email inbox seems a bit of an overkill to me.

Upvotes: 0

Views: 111

Answers (1)

Arnaud Rinquin
Arnaud Rinquin

Reputation: 4306

You should write 3 tests

  • the insertion of an activation token in your system
  • the activation API works properly when called
  • the component that builds the URL before it's inserted into the mail template (and rely on the template engine to keep this correct data)

Run this tests separately, don't try to run the full history. Less coupling between your components means better quality. Test you API on one side, test your mail builder on the other.

Upvotes: 1

Related Questions