
3
Tools for testing your code
I'm curious as to what tools people use to test their code.
I work with a few email systems that require certain variables to be included in the code. For example, Campaign Monitor requires a special <unsubscribe> tag in order to be deployed.
Each system I work with has something unique about it. So I figured I would start using a testing framework like Mocha to test for those special variables during/after my build. This may sound like a bit much, but if you develop a lot of emails, there's always a chance something will slip by.
I'm currently using gulpjs with Mocha to run my tests and it's working great.
Do any of you do this kind of testing?
That's definitely an interesting approach.
Most ESPs I've used always throw up an error if required tags aren't present, so I haven't run into any huge issues with missing tags, but I understand where you're coming from. If you're developing a ton of emails, it would save a lot of time to have a process in place that tests before you upload your code to an ESP.
Do you have any other Gulp recipes set up to handle things like code validation, minification, or inlining of styles at the same time?
One of the systems we work with I never really touch, I just hand the code off to the project manager who uploads it. So it's good to catch errors before giving it to them.
The main gulp plugins I use are:
gulp-inline-css - Inlines css
gulp-htmlhint - Checks for html errors
gulp-htmlmin - Minifies html
gulp-litmus - send tests to Litmus
gulp-special-html - Encodes special characters
browsersync - Syncs browser and devices, refreshes on change
Now I'm working with gulp-mocha to create my tests for each system. I use a combination of the cheerio module and regular expressions to parse the html looking for specific variables.
That's awesome. I've been meaning to try out more automated build systems for email, just haven't had the chance yet. I know there are a few people in Community that are all about tools and process and are finally bringing email development up to par with modern web development, which is amazing to see.
If you ever have the time, I'm sure I'm not the only one that would love to get a more in-depth look into your tools setup and process. Perhaps via an article in the Learning Center?
Yeah I've thought about writing a article but I'm always finding better ways of doing things that I just never get around to it.
This sounds great.
We have a lot of sensitive info/content at work and using any outside service wouldn't be good for us.
Is there a way to send html emails using Mavericks Terminal? I thought about Mail but I'm afraid it may wrap the code with something that could throw it off. I don't want any kind of wrapper around the html. I want to be able to send the html as is.
Thanks in advance.
Frank (this is a company acct).
Once finished, I do number of tests on various clients/devices and if everything is looking good, it is good.
I might also throw it through w3c validator to check for any unclosed tags and such if the code was longer.
I'm usually doing my emails for use on one ESP so I got their tags pretty much in my system.If it is somewhere else, I prepare for their tags and just check manually everything again. Usually I get some kind of an error if anything is missed.
I can understand though if you are doing allot of emails daily, some kind of automation helps allot.
I've just set up a grunt workflow for our emails.
I use grunt-includereplace and grunt-bake to build our emails from a load of include files. The unsubscribe links and things like that tend to be in the header or footer of the templates which don't get updated much so we don't need to worry about that but I like the idea building some automated testing for a few other bits. It's great idea.
Hi Mark,
How well does this work? I use a ton of include files and basic logic using server-side-includes but it doesn't scale well when we start to add more team members... can you show me a very minor example?
Very interested in more automation...
Hi Nathan,
So we have about 10 offers and about 10 partner templates. The offers change every month but the templates stay pretty much the same. So each week need to put the offers into the templates.
So I start by creating an HTML file that defines the partner, offer and a couple of other parameters I'll leave out for now to keep things simple.
That then creates our build files which then pull in all the includes. It looks a little like this
<!--(bake ../emails/templates/top.html partner="@@partner")-->
<!--(bake ../emails/templates/offer/@@offer.css)-->
<!--(bake ../emails/templates/partner/@@partner-top.html)-->
<!--(bake ../emails/templates/offer/@@offer.html partner="@@partner")-->
<!--(bake ../emails/templates/partner/@@partner-bottom.html)-->
<!--(bake ../emails/templates/bottom.html offer="@@offer")-->
I'm the only one using this currently but to scale it up I'd think you could retrieve the files from a server as the first task before the build.
Does that make any sense? :)
Hi Mark,
Thanks, I'm still getting my feet wet with grunt and gulp, but one day soon (that mythical day when I have a lot of time to make some workflow changes) I'll be diving deep into this.
Looks really useful, and honestly pretty much the same way I work right now.
Cheers
I've only just got started too, spent a bit of time reading up on things and planning roughly what I wanted then booked out a day with no distractions to get it set up.
Good luck on finding some time.